Skip to content

Commit

Permalink
adding "type" param to group and set all it's node with it, if given
Browse files Browse the repository at this point in the history
  • Loading branch information
raimannma authored and christianechevarria committed Apr 12, 2020
1 parent 7fb8a0e commit e1bae89
Showing 1 changed file with 24 additions and 19 deletions.
43 changes: 24 additions & 19 deletions src/architecture/group.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,25 @@ const config = require('../config');
const Node = require('./node');

/**
* A group instance denotes a group of nodes. Beware: once a group has been used to construct a network, the groups will fall apart into individual nodes. They are purely for the creation and development of networks.
*
* @constructs Group
*
* @param {number} [size=0] Amount of nodes to build group with
*
* @prop {Nodes[]} [nodes=[]] All nodes within the group
* @prop {Connection[]} [incoming=[]] Incoming connections
* @prop {Connection[]} [outgoing=[]] Outgoing connections
* @prop {Connection[]} [connections_self=[]] Self connections
*
* @example
* let { Group } = require("@liquid-carrot/carrot");
*
* // A group with 5 nodes
* let A = new Group(5);
*/
function Group(size) {
* A group instance denotes a group of nodes. Beware: once a group has been used to construct a network, the groups will fall apart into individual nodes. They are purely for the creation and development of networks.
*
* @constructs Group
*
* @param {number} [size=0] Amount of nodes to build group with
*
* @param {String} type the type of nodes inside the group
* @prop {Nodes[]} [nodes=[]] All nodes within the group
* @prop {Connection[]} [incoming=[]] Incoming connections
* @prop {Connection[]} [outgoing=[]] Outgoing connections
* @prop {Connection[]} [connections_self=[]] Self connections
*
* @example
* let { Group } = require("@liquid-carrot/carrot");
*
* // A group with 5 nodes
* let A = new Group(5);
*/
function Group(size,type) {
const self = this;

// Important:
Expand All @@ -32,7 +33,11 @@ function Group(size) {
self.outgoing = [];

for (let index = 0; index < size; index++) {
self.nodes.push(new Node());
const node = new Node();
if(type) {
node.type = type;
}
self.nodes.push(node);
}

/**
Expand Down

0 comments on commit e1bae89

Please sign in to comment.