Network Geography

To create connections and remove connections between agents you can use the Connect() and Unconnect() functions. Both of these functions take one argument: the agents that should be connected or disconnected. For example, to connect an agent to its nearest neighbor, you could use the following:


To disconnect an agent from its nearest neighbor (assuming they are connected), you would use:


To obtain a vector of connections to an agent, use the Connected() function:


Connections are not directed so creating a connection from agent A to agent B is the same as creating a connection from agent B to agent A. Also only one connection between a given pair of agents will exist at a time. So creating two connections between a given pair of agents will have the same effect as creating a single connection.

By default, no connections are created when a simulation is initially started. If you change the Network Structure configuration property of the agent population primitive, you can specify a function to create connections when the simulation is started. This function is called once for each pair of agents in the model. The agents are available in the function as the variables a and b. If the function evaluates to true, then the agents will start connected. If the function evaluates to false, the agents will not be initially connected.

You could use this function to, for instance, specify that 40% of agents will be directly connected to each other at the start of the simulation. The following equation would do that by generating a random true/false value with 40% probability of returning true each time it is called: