flocc.Network class (from here on, just
Network) stores agents in an undirected graph, allowing you to create and keep track of connections between agents.
An empty network can be instantiated by calling:
const network = new Network();
Then, to make sure that your environment recognizes and can make use of the
Network, make sure you call:
network is the instance of the
Network you created earlier).
Add an agent to the network.
const agent = new Agent(); environment.addAgent(agent); network.addAgent(agent);
Add all agents from an environment to the network.
Remove a previously referenced agent from the network. If
a1 is an agent removed from the network, and has a connection to
a2 will remain in the network but its connection to
a1 will be removed.
Removes all agents from the network, as well as all connections.
agent2. This method returns
true if the connection was successful, that is:
It will return
false if the connection was unsuccessful, for example if you try to connect an agent to itself, or to connect two already-connected agents, or to connect an/two agent/s not in the network (it will otherwise fail silently).
Returns a boolean
true if the agents are connected,
false if they are not.
.connect, this method returns
true if the disconnection was successful and
false if it was unsuccessful (it will otherwise fail silently).
Returns the number of agents in the network. Since the size of the network is distinct from the environment, you might have fewer agents in the network than are in the environment.
Returns a boolean
true if the agent is in the network,
false if it is not.
This helper function adds connections between every agent in the network to every other agent. Since there are no more possible connections that could be created, the network is now complete. Read more about complete graphs.