Grid graph using networkx

[1]:
import networkx as nx

import pop2net as p2n


class MyAgent(p2n.Agent):
    pass


class Grid(p2n.LocationDesigner):
    nxgraph = nx.grid_2d_graph(4, 4)


model = p2n.Model()
creator = p2n.Creator(model)
inspector = p2n.NetworkInspector(model)

for _ in range(16):
    p2n.Agent(model)

creator.create_locations(location_designers=[Grid])
[1]:
LocationList (24 objects)
[2]:
g = nx.grid_2d_graph(5, 5)
[3]:
inspector.plot_bipartite_network()
[4]:
inspector.plot_agent_network()