Caveman graph
Example I - Unconnected caves
[4]:
import pop2net as p2n
model = p2n.Model()
creator = p2n.Creator(model)
inspector = p2n.NetworkInspector(model)
class Cave(p2n.LocationDesigner):
n_agents = 5
for _ in range(25):
p2n.Agent(model)
creator.create_locations(location_designers=[Cave])
inspector.plot_networks()
Example II - Connected grid caves
[5]:
import networkx as nx
model = p2n.Model()
creator = p2n.Creator(model)
inspector = p2n.NetworkInspector(model)
class Cave(p2n.LocationDesigner):
nxgraph = nx.grid_2d_graph(3, 3)
class Bridge(p2n.LocationDesigner):
nxgraph = nx.cycle_graph(5)
def filter(self, agent):
return agent.Cave_head
for _ in range(45):
p2n.Agent(model)
creator.create_locations(
location_designers=[
Cave,
Bridge,
]
)
inspector.plot_networks()