Barabási–Albert Network
This behavior generates agents connected on a Barabási–Albert network. Networks generated using this behavior have the "scale-free" property, that is, the degree distribution follows a power law.
Published by
Shortname
@eadan/create_barabasi_albert_network.js
Description

This behavior generates agents connected on a Barabási–Albert network. Networks generated using this behavior have the "scale-free" property, that is, the degree distribution follows a power law.

The following variables controlling the structure of the network:

  • num_nodes: (int) number of nodes (i.e. agents) in the network.
  • avg_degree: (int) average degree of the network.

This behavior is intended to be used in conjunction with @hash/create_agents.js. A minimal init.json is:

[
  {
    "agent_id": "network_creator",
    "behaviors": [
      "@eadan/create_barabasi_albert_network.js",
      "@hash/create_agents.js",
      "@hash/remove_self.js"
    ],
    "network_template": {
      "name": "person",
      "num_nodes": 1000,
      "avg_degree": 10,
      "behaviors": ["AGENT_BEHAVIOR_1.js", "AGENT_BEHAVIOR_2.js"],
      "field_a": "xyz"
    }
  }
]

The state of each agent in the network will be populated with a neighbors field containing a list of agent IDs. These IDs may be used to message an agent's neighbors. For example:

for (agentID of state.get("neighbors") {
  state.addMessage(agentID, "hello", {name: "Alice"});
}