Connected opinion clusters

[1]:
import pop2net as p2n


class OpinionCluster(p2n.LocationDesigner):
    def split(self, agent):
        return agent.opinion


class Bridge(p2n.LocationDesigner):
    n_locations = 1

    def bridge(self, agent):
        return agent.opinion


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

for i in range(30):
    agent = p2n.Agent(model=model)
    agent.opinion = i % 3

creator.create_locations(
    location_designers=[
        OpinionCluster,
        Bridge,
    ]
)

inspector.plot_networks(agent_color="opinion")