Small world using networkx

[2]:
import networkx as nx

import pop2net as p2n


class MyAgent(p2n.Agent):
    pass


class SmallWorld(p2n.LocationDesigner):
    nxgraph = nx.watts_strogatz_graph(n=50, k=4, p=0.05)


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

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

creator.create_locations(location_designers=[SmallWorld])
[2]:
LocationList (100 objects)
[3]:
inspector.plot_bipartite_network()
[4]:
inspector.plot_agent_network()