Connected opinion clusters

[1]:
import pop2net as p2n


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


class Bridge(p2n.LocationDesigner):
    n_locations = 1

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


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

for i in range(30):
    actor = p2n.Actor()
    actor.opinion = i % 3
    env.add_actor(actor)

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

inspector.plot_networks(actor_color="opinion")