Lollipop graph

Example I - Simple Lollipop using networkx

[1]:
import networkx as nx

import pop2net as p2n

env = p2n.Environment()
creator = p2n.Creator(env)
inspector = p2n.NetworkInspector(env)


class Lollipop(p2n.LocationDesigner):
    nxgraph = nx.lollipop_graph(5, 3)


env.add_actors([p2n.Actor() for _ in range(24)])

creator.create_locations(
    location_designers=[
        Lollipop,
    ]
)

inspector.plot_networks()

Example II - A Lollipop star

[2]:
env = p2n.Environment()
creator = p2n.Creator(env)
inspector = p2n.NetworkInspector(env)


class Lollipop(p2n.LocationDesigner):
    n_locations = 5
    nxgraph = nx.lollipop_graph(5, 3)
    only_exact_n_actors = True


class Center(p2n.LocationDesigner):
    def filter(self, actor):
        return actor.Lollipop_tail or not actor.Lollipop

    def bridge(self, actor):
        return actor.Lollipop_assigned


env.add_actors([p2n.Actor() for _ in range(41)])

creator.create_locations(
    location_designers=[
        Lollipop,
        Center,
    ]
)

inspector.plot_networks()