Complete graph
Example I: Simple complete graph using pop2net only
[1]:
import pop2net as p2n
class FullyConnected(p2n.LocationDesigner):
pass
model = p2n.Model()
creator = p2n.Creator(model)
inspector = p2n.NetworkInspector(model)
for _ in range(5):
p2n.Agent(model)
creator.create_locations(location_designers=[FullyConnected])
[1]:
LocationList (1 object)
[2]:
inspector.plot_bipartite_network()
[3]:
inspector.plot_agent_network()
Example II: Complete graph with one location for each bilateral relation using networkx
[4]:
import networkx as nx
class FullyConnected(p2n.LocationDesigner):
nxgraph = nx.complete_graph(n=5)
model = p2n.Model()
creator = p2n.Creator(model)
inspector = p2n.NetworkInspector(model)
for _ in range(5):
p2n.Agent(model)
creator.create_locations(location_designers=[FullyConnected])
[4]:
LocationList (10 objects)
[5]:
inspector.plot_bipartite_network()
[6]:
inspector.plot_agent_network()