Networks¶
Base and Factory¶
- class terrarium.networks.base.CommunicationNetwork(graph, consolidate_channels_enabled=False)[source]¶
Bases:
objectA NetworkX-backed communication network.
Convention used across Terrarium:
Nodes are agent names (strings).
Edges are potential pairwise connections; blackboard channels are derived from this graph via channel_groups().
- Parameters:
graph (Graph)
consolidate_channels_enabled (bool)
- channel_groups()[source]¶
Return communication channel groups (blackboard participants) for this network.
- consolidate_channels()[source]¶
Return a greedy clique-based channel cover as communication channels.
Example: A complete graph with n nodes/agents –> one channel/blackboard with all n agents.
Algorithm:
Repeatedly find a clique (size >= 3), create a multi-participant channel for it, remove those nodes, and repeat.
When no cliques (size >= 3) remain, create one channel per remaining edge.
Finally, ensure the resulting channel graph is connected by adding a small number of pairwise channels that connect otherwise-disconnected channel components (preferring edges that existed in the original graph).
Notes:
This is an NP-hard problem, so finding an optimal solution is not feasible.
This algorithm may dominate computation time for large graphs.
Clique selection is greedy: pick the largest clique each iteration.
Clique channels are vertex-disjoint, but connectivity edges added at the end may cause some agents to participate in multiple channels.
- terrarium.networks.factory.build_communication_network(agent_names, config)[source]¶
Build a CommunicationNetwork from config.
Supported config keys:
communication_network.topology (required) Values: complete | path | star | erdos_renyi | watts_strogatz | barabasi_albert
communication_network.consolidate_channels (optional bool; default false)
communication_network.center (only for star; agent name or integer index)
communication_network.edge_prob (erdos_renyi; float in [0, 1])
communication_network.k (watts_strogatz; even int < num_agents)
communication_network.rewire_prob (watts_strogatz; float in [0, 1])
communication_network.m (barabasi_albert; int in [1, num_agents-1])
random graph seed is taken from simulation.seed for random graph families
Topologies¶
- class terrarium.networks.complete.CompleteNetwork(agent_names, *, consolidate_channels=False)[source]¶
Bases:
CommunicationNetworkFully-connected (clique) communication network.
- class terrarium.networks.path.PathNetwork(agent_names, *, consolidate_channels=False)[source]¶
Bases:
CommunicationNetworkPath topology where each agent connects to its immediate neighbours.
- class terrarium.networks.star.StarNetwork(agent_names, *, center=None, consolidate_channels=False)[source]¶
Bases:
CommunicationNetworkStar topology with a single hub connected to all other agents.
- class terrarium.networks.erdos_renyi.ErdosRenyiNetwork(agent_names, *, edge_prob, seed=None, consolidate_channels=False)[source]¶
Bases:
CommunicationNetworkErdos-Renyi G(n, p) random communication network.
- class terrarium.networks.watts_strogatz.WattsStrogatzNetwork(agent_names, *, k, rewire_prob, seed=None, consolidate_channels=False)[source]¶
Bases:
CommunicationNetworkWatts-Strogatz small-world communication network.
- class terrarium.networks.barabasi_albert.BarabasiAlbertNetwork(agent_names, *, m, seed=None, consolidate_channels=False)[source]¶
Bases:
CommunicationNetworkBarabasi-Albert preferential attachment communication network.