From 5d5f35a6a1099b206ba2fcedd3f4c0c54536f74b Mon Sep 17 00:00:00 2001 From: Spartan-71 Date: Thu, 27 Mar 2025 21:54:54 +0530 Subject: [PATCH 1/6] feat: initial model --- examples/preferencial_attachment/agents.py | 10 ++++++ examples/preferencial_attachment/app.py | 25 ++++++++++++++ examples/preferencial_attachment/model.py | 40 ++++++++++++++++++++++ 3 files changed, 75 insertions(+) create mode 100644 examples/preferencial_attachment/agents.py create mode 100644 examples/preferencial_attachment/app.py create mode 100644 examples/preferencial_attachment/model.py diff --git a/examples/preferencial_attachment/agents.py b/examples/preferencial_attachment/agents.py new file mode 100644 index 00000000..fa9aa6c5 --- /dev/null +++ b/examples/preferencial_attachment/agents.py @@ -0,0 +1,10 @@ +from mesa.discrete_space import FixedAgent + +class NodeAgent(FixedAgent): + + def __init__(self,model,cell): + super().__init__(model) + self.cell = cell + + + diff --git a/examples/preferencial_attachment/app.py b/examples/preferencial_attachment/app.py new file mode 100644 index 00000000..96688c04 --- /dev/null +++ b/examples/preferencial_attachment/app.py @@ -0,0 +1,25 @@ +import solara +from model import AgentNetwork +from mesa.visualization import ( + Slider, + SolaraViz, + make_plot_component, + make_space_component, +) + +def node_portrayal(agent): + return{ + "color": "blue", + "size": 30 + } + +SpacePlot = make_space_component(node_portrayal) + +model = AgentNetwork() + +page = SolaraViz( + model, + components=[SpacePlot], + # model_params=model_params, + name= "Agent Network" +) diff --git a/examples/preferencial_attachment/model.py b/examples/preferencial_attachment/model.py new file mode 100644 index 00000000..3b0ff3b9 --- /dev/null +++ b/examples/preferencial_attachment/model.py @@ -0,0 +1,40 @@ +import networkx as nx +import numpy as np +from mesa import Model +from mesa.discrete_space import Network + +from agents import NodeAgent + +class AgentNetwork(Model): + + def __init__(self,seed=None): + super().__init__(seed=seed) + self.graph = nx.Graph() + self.graph.add_node(0) + self.graph.add_node(1) + self.graph.add_edge(0,1) + self.new_node=1 + self.grid = Network(self.graph,capacity=1,random=self.random) + NodeAgent.create_agents(model=self,n=2,cell=list(self.grid.all_cells)) + + + def step(self): + print("taking steppp...........") + self.new_node += 1 + self.graph.add_node(self.new_node) + + # extract node IDs along with their degrees + nodes, degree = zip(*self.graph.degree()) + total_degree = sum(degree) + + # probabilities of connecting to an existing node + probabilities = [d/total_degree for d in degree] + + # choose an existing node based on the computed probabilities + chosen_node = np.random.choice(nodes, p=probabilities) + + # add the new node and connect it to the choosen node + self.graph.add_edge(chosen_node,self.new_node) + + # for x in self.agents: + # print(x.unique_id) \ No newline at end of file From 00497509a0afe6f1c2685f5c5bb0de58c9ea2ad9 Mon Sep 17 00:00:00 2001 From: Spartan-71 Date: Thu, 10 Apr 2025 21:50:33 +0530 Subject: [PATCH 2/6] feat: added no. of agents as parameter --- examples/preferencial_attachment/app.py | 10 +++++-- examples/preferencial_attachment/model.py | 35 +++++++++++++++++------ 2 files changed, 35 insertions(+), 10 deletions(-) diff --git a/examples/preferencial_attachment/app.py b/examples/preferencial_attachment/app.py index 96688c04..c897c8fb 100644 --- a/examples/preferencial_attachment/app.py +++ b/examples/preferencial_attachment/app.py @@ -13,13 +13,19 @@ def node_portrayal(agent): "size": 30 } -SpacePlot = make_space_component(node_portrayal) +def post_process_lineplot(ax): + ax.set_ylim(ymin=0) + ax.set_ylabel("# total degree") + ax.set_xlim(xmin=0) + ax.legend(bbox_to_anchor=(1.05, 1.0), loc="upper left") +SpacePlot = make_space_component(node_portrayal) +StatePlot = make_plot_component(measure = "Degree",post_process=post_process_lineplot) model = AgentNetwork() page = SolaraViz( model, - components=[SpacePlot], + components=[SpacePlot,StatePlot], # model_params=model_params, name= "Agent Network" ) diff --git a/examples/preferencial_attachment/model.py b/examples/preferencial_attachment/model.py index 3b0ff3b9..489ded04 100644 --- a/examples/preferencial_attachment/model.py +++ b/examples/preferencial_attachment/model.py @@ -1,27 +1,44 @@ import networkx as nx import numpy as np -from mesa import Model +from mesa import Model, DataCollector from mesa.discrete_space import Network from agents import NodeAgent +def calculate_total_degree(model): + _ , degree = zip(*model.graph.degree()) + return sum(degree) + class AgentNetwork(Model): - def __init__(self,seed=None): + def __init__(self,num=100,seed=None): super().__init__(seed=seed) + self.num = num self.graph = nx.Graph() - self.graph.add_node(0) - self.graph.add_node(1) - self.graph.add_edge(0,1) self.new_node=1 + for i in range(self.num): + self.graph.add_node(i) + + self.graph.add_edge(0,1) + + self.datacollector = DataCollector( + { + "Degree": calculate_total_degree, + } + ) + self.grid = Network(self.graph,capacity=1,random=self.random) - NodeAgent.create_agents(model=self,n=2,cell=list(self.grid.all_cells)) + NodeAgent.create_agents(model=self,n=self.num,cell=list(self.grid.all_cells)) def step(self): print("taking steppp...........") self.new_node += 1 - self.graph.add_node(self.new_node) + + # if self.new_node >= self.num: + # break + + # self.graph.add_node(self.new_node) # extract node IDs along with their degrees nodes, degree = zip(*self.graph.degree()) @@ -37,4 +54,6 @@ def step(self): self.graph.add_edge(chosen_node,self.new_node) # for x in self.agents: - # print(x.unique_id) \ No newline at end of file + # print(x.unique_id) + + self.datacollector.collect(self) \ No newline at end of file From 3962a245a9b9a7ff6fc7f8ad48a2e92572e01028 Mon Sep 17 00:00:00 2001 From: Spartan-71 Date: Fri, 11 Apr 2025 09:46:57 +0530 Subject: [PATCH 3/6] chore: restructured --- examples/preferencial_attachment/README.md | 0 examples/preferencial_attachment/app.py | 33 ++++++++++++++----- .../preferencial_attachment/__init__.py | 0 .../{ => preferencial_attachment}/agents.py | 0 .../{ => preferencial_attachment}/model.py | 29 ++++++++-------- 5 files changed, 40 insertions(+), 22 deletions(-) create mode 100644 examples/preferencial_attachment/README.md create mode 100644 examples/preferencial_attachment/preferencial_attachment/__init__.py rename examples/preferencial_attachment/{ => preferencial_attachment}/agents.py (100%) rename examples/preferencial_attachment/{ => preferencial_attachment}/model.py (70%) diff --git a/examples/preferencial_attachment/README.md b/examples/preferencial_attachment/README.md new file mode 100644 index 00000000..e69de29b diff --git a/examples/preferencial_attachment/app.py b/examples/preferencial_attachment/app.py index c897c8fb..8ab58c14 100644 --- a/examples/preferencial_attachment/app.py +++ b/examples/preferencial_attachment/app.py @@ -1,5 +1,5 @@ import solara -from model import AgentNetwork +from preferencial_attachment.model import AgentNetwork from mesa.visualization import ( Slider, SolaraViz, @@ -13,19 +13,34 @@ def node_portrayal(agent): "size": 30 } -def post_process_lineplot(ax): - ax.set_ylim(ymin=0) - ax.set_ylabel("# total degree") - ax.set_xlim(xmin=0) - ax.legend(bbox_to_anchor=(1.05, 1.0), loc="upper left") +# def post_process_lineplot(ax): +# ax.set_ylim(ymin=0) +# ax.set_ylabel("# total degree") +# ax.set_xlim(xmin=0) +# ax.legend(bbox_to_anchor=(1.05, 1.0), loc="upper left") +model_params = { + "num": { + "type": "SliderInt", + "value": 50, + "label": "No. of agents", + "min": 10, + "max":150, + "step": 1, + }, + "seed": { + "type": "InputText", + "value": 42, + "label": "Random Seed", + }, +} SpacePlot = make_space_component(node_portrayal) -StatePlot = make_plot_component(measure = "Degree",post_process=post_process_lineplot) +# StatePlot = make_plot_component(measure = "Degree",post_process=post_process_lineplot) model = AgentNetwork() page = SolaraViz( model, - components=[SpacePlot,StatePlot], - # model_params=model_params, + components=[SpacePlot], + model_params=model_params, name= "Agent Network" ) diff --git a/examples/preferencial_attachment/preferencial_attachment/__init__.py b/examples/preferencial_attachment/preferencial_attachment/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/examples/preferencial_attachment/agents.py b/examples/preferencial_attachment/preferencial_attachment/agents.py similarity index 100% rename from examples/preferencial_attachment/agents.py rename to examples/preferencial_attachment/preferencial_attachment/agents.py diff --git a/examples/preferencial_attachment/model.py b/examples/preferencial_attachment/preferencial_attachment/model.py similarity index 70% rename from examples/preferencial_attachment/model.py rename to examples/preferencial_attachment/preferencial_attachment/model.py index 489ded04..37dd63f6 100644 --- a/examples/preferencial_attachment/model.py +++ b/examples/preferencial_attachment/preferencial_attachment/model.py @@ -3,16 +3,17 @@ from mesa import Model, DataCollector from mesa.discrete_space import Network -from agents import NodeAgent +from .agents import NodeAgent -def calculate_total_degree(model): - _ , degree = zip(*model.graph.degree()) - return sum(degree) +# def calculate_total_degree(model): +# _ , degree = zip(*model.graph.degree()) +# return sum(degree) class AgentNetwork(Model): - def __init__(self,num=100,seed=None): + def __init__(self,num=100,seed=42): super().__init__(seed=seed) + self.random = seed self.num = num self.graph = nx.Graph() self.new_node=1 @@ -21,18 +22,17 @@ def __init__(self,num=100,seed=None): self.graph.add_edge(0,1) - self.datacollector = DataCollector( - { - "Degree": calculate_total_degree, - } - ) + # self.datacollector = DataCollector( + # { + # "Degree": calculate_total_degree, + # } + # ) self.grid = Network(self.graph,capacity=1,random=self.random) - NodeAgent.create_agents(model=self,n=self.num,cell=list(self.grid.all_cells)) + NodeAgent.create_agents(model=self,n=self.num,cell=list(self.grid.all_cells),) def step(self): - print("taking steppp...........") self.new_node += 1 # if self.new_node >= self.num: @@ -41,7 +41,10 @@ def step(self): # self.graph.add_node(self.new_node) # extract node IDs along with their degrees + print(self.graph.degree()) nodes, degree = zip(*self.graph.degree()) + print(f"nodes: {nodes}") + print(f"degree: {type(degree)}") total_degree = sum(degree) # probabilities of connecting to an existing node @@ -56,4 +59,4 @@ def step(self): # for x in self.agents: # print(x.unique_id) - self.datacollector.collect(self) \ No newline at end of file + # self.datacollector.collect(self) \ No newline at end of file From 114c1ec92f3f091a4bd30eb0cd5fbeededa1846f Mon Sep 17 00:00:00 2001 From: Spartan-71 Date: Mon, 14 Apr 2025 08:33:04 +0530 Subject: [PATCH 4/6] feat: added line-plot for monitoring the nodes --- examples/preferencial_attachment/README.md | 47 ++++++++++++++ examples/preferencial_attachment/app.py | 37 +++++------ .../preferencial_attachment/agents.py | 6 +- .../preferencial_attachment/model.py | 63 +++++++++---------- 4 files changed, 99 insertions(+), 54 deletions(-) diff --git a/examples/preferencial_attachment/README.md b/examples/preferencial_attachment/README.md index e69de29b..a46717e3 100644 --- a/examples/preferencial_attachment/README.md +++ b/examples/preferencial_attachment/README.md @@ -0,0 +1,47 @@ +# Preferential Attachment Network + +This model simulates the generation of **scale-free networks** using **preferential attachment**, inspired by the NetLogo [Preferential Attachment model](http://ccl.northwestern.edu/netlogo/models/PreferentialAttachment). It demonstrates how "hubs" with many connections emerge naturally when new nodes prefer to connect to already well-connected nodes. + +## Summary + +In this simulation, new nodes are added to a growing network one by one. Each new node connects to an existing node, where the probability of connection is **proportional to the degree** (number of connections) of the existing nodes. This leads to the formation of **Barabási-Albert scale-free networks**, where a few nodes (hubs) accumulate many connections, while most nodes have very few. + +Such networks are common in real-world systems such as: +- The World Wide Web (webpages linking to other pages), +- Social networks (users connecting with popular accounts), +- Citation networks (new papers citing widely cited publications). + +## Installation + +Ensure that you have installed the latest version of **Mesa**. + + +## Usage + +To run the simulation: + +```bash +solara run app.py +``` + +## Model Details + +### Agents + +- **NodeAgent**: Represents a node in the network. Each agent keeps track of its degree and updates its connections as the network grows. New nodes prefer connecting to higher-degree nodes, simulating the preferential attachment process. + +### Environment + +- **Network**: The model uses Mesa's `Network` to maintain the graph structure, initialized with the fixed no. of agents. Each step connects a node to the existing network, and the visualization updates to reflect the current state of the network. + + +### Agent Behaviors + +- **Preferential Connection**: When a new node is added, it connects to one existing node, with a probability weighted by the existing node’s degree. +- **Growth Step**: Each step corresponds to one node being added to the network. +- **Degree Monitoring**: A line plot is used to track the nodes with degree one. + +## References + +- Wilensky, U. (2005). *NetLogo Preferential Attachment model*. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL. Available at: [NetLogo Preferential Attachment](http://ccl.northwestern.edu/netlogo/models/PreferentialAttachment) +- Barabási, A.-L., & Albert, R. (1999). *Emergence of scaling in random networks*. Science, 286(5439), 509-512. \ No newline at end of file diff --git a/examples/preferencial_attachment/app.py b/examples/preferencial_attachment/app.py index 8ab58c14..ab2fd034 100644 --- a/examples/preferencial_attachment/app.py +++ b/examples/preferencial_attachment/app.py @@ -1,11 +1,10 @@ -import solara -from preferencial_attachment.model import AgentNetwork from mesa.visualization import ( - Slider, SolaraViz, make_plot_component, make_space_component, ) +from preferencial_attachment.model import AgentNetwork + def node_portrayal(agent): return{ @@ -13,34 +12,36 @@ def node_portrayal(agent): "size": 30 } -# def post_process_lineplot(ax): -# ax.set_ylim(ymin=0) -# ax.set_ylabel("# total degree") -# ax.set_xlim(xmin=0) -# ax.legend(bbox_to_anchor=(1.05, 1.0), loc="upper left") - model_params = { + "seed": { + "type": "InputText", + "value": 42, + "label": "Random Seed", + }, "num": { "type": "SliderInt", - "value": 50, + "value": 30, "label": "No. of agents", "min": 10, - "max":150, + "max":100, "step": 1, }, - "seed": { - "type": "InputText", - "value": 42, - "label": "Random Seed", - }, } + +def post_process_lineplot(ax): + ax.set_ylim(ymin=0) + ax.set_xlim(xmin=0) + ax.set_ylabel("Nodes with Degree 1") + ax.set_xlabel("Steps") + + SpacePlot = make_space_component(node_portrayal) -# StatePlot = make_plot_component(measure = "Degree",post_process=post_process_lineplot) +StatePlot = make_plot_component(measure = "Degree",post_process=post_process_lineplot) model = AgentNetwork() page = SolaraViz( model, - components=[SpacePlot], + components=[SpacePlot,StatePlot], model_params=model_params, name= "Agent Network" ) diff --git a/examples/preferencial_attachment/preferencial_attachment/agents.py b/examples/preferencial_attachment/preferencial_attachment/agents.py index fa9aa6c5..32fc850b 100644 --- a/examples/preferencial_attachment/preferencial_attachment/agents.py +++ b/examples/preferencial_attachment/preferencial_attachment/agents.py @@ -1,10 +1,8 @@ from mesa.discrete_space import FixedAgent + class NodeAgent(FixedAgent): - def __init__(self,model,cell): + def __init__(self,model,cell): super().__init__(model) self.cell = cell - - - diff --git a/examples/preferencial_attachment/preferencial_attachment/model.py b/examples/preferencial_attachment/preferencial_attachment/model.py index 37dd63f6..e57713bd 100644 --- a/examples/preferencial_attachment/preferencial_attachment/model.py +++ b/examples/preferencial_attachment/preferencial_attachment/model.py @@ -1,50 +1,50 @@ import networkx as nx import numpy as np -from mesa import Model, DataCollector +from mesa import DataCollector, Model from mesa.discrete_space import Network from .agents import NodeAgent -# def calculate_total_degree(model): -# _ , degree = zip(*model.graph.degree()) -# return sum(degree) + +def calculate_nodes_with_degree_1(model): + _ , degree = zip(*model.graph.degree()) + return sum(1 for deg in degree if deg==1) class AgentNetwork(Model): - - def __init__(self,num=100,seed=42): + + def __init__(self,num=30,seed=42): + """Initialize the model. + + Args: + num: Number of Node Agents, + seed : Random seed for reproducibility. + """ super().__init__(seed=seed) - self.random = seed self.num = num + self.random = seed + self.curr_node=1 self.graph = nx.Graph() - self.new_node=1 + + # Adding nodes to the graph for i in range(self.num): self.graph.add_node(i) self.graph.add_edge(0,1) - # self.datacollector = DataCollector( - # { - # "Degree": calculate_total_degree, - # } - # ) - - self.grid = Network(self.graph,capacity=1,random=self.random) - NodeAgent.create_agents(model=self,n=self.num,cell=list(self.grid.all_cells),) - + self.datacollector = DataCollector( + { + "Degree": calculate_nodes_with_degree_1, + } + ) - def step(self): - self.new_node += 1 + self.grid = Network(self.graph,capacity=1,random=self.random) + NodeAgent.create_agents(model=self,n=self.num,cell=list(self.grid.all_cells)) - # if self.new_node >= self.num: - # break - - # self.graph.add_node(self.new_node) - # extract node IDs along with their degrees - print(self.graph.degree()) + def step(self): + self.curr_node += 1 + nodes, degree = zip(*self.graph.degree()) - print(f"nodes: {nodes}") - print(f"degree: {type(degree)}") total_degree = sum(degree) # probabilities of connecting to an existing node @@ -54,9 +54,8 @@ def step(self): chosen_node = np.random.choice(nodes, p=probabilities) # add the new node and connect it to the choosen node - self.graph.add_edge(chosen_node,self.new_node) - - # for x in self.agents: - # print(x.unique_id) + self.graph.add_edge(chosen_node,self.curr_node) - # self.datacollector.collect(self) \ No newline at end of file + self.datacollector.collect(self) + if self.steps >= self.num - 2: + self.running = False From 5732a56b82090041bd5fb54b287ad92fbb21048e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 14 Apr 2025 03:14:55 +0000 Subject: [PATCH 5/6] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- examples/preferencial_attachment/app.py | 15 ++++++------ .../preferencial_attachment/agents.py | 3 +-- .../preferencial_attachment/model.py | 23 +++++++++---------- 3 files changed, 19 insertions(+), 22 deletions(-) diff --git a/examples/preferencial_attachment/app.py b/examples/preferencial_attachment/app.py index ab2fd034..548766c9 100644 --- a/examples/preferencial_attachment/app.py +++ b/examples/preferencial_attachment/app.py @@ -7,10 +7,8 @@ def node_portrayal(agent): - return{ - "color": "blue", - "size": 30 - } + return {"color": "blue", "size": 30} + model_params = { "seed": { @@ -23,11 +21,12 @@ def node_portrayal(agent): "value": 30, "label": "No. of agents", "min": 10, - "max":100, + "max": 100, "step": 1, }, } + def post_process_lineplot(ax): ax.set_ylim(ymin=0) ax.set_xlim(xmin=0) @@ -36,12 +35,12 @@ def post_process_lineplot(ax): SpacePlot = make_space_component(node_portrayal) -StatePlot = make_plot_component(measure = "Degree",post_process=post_process_lineplot) +StatePlot = make_plot_component(measure="Degree", post_process=post_process_lineplot) model = AgentNetwork() page = SolaraViz( model, - components=[SpacePlot,StatePlot], + components=[SpacePlot, StatePlot], model_params=model_params, - name= "Agent Network" + name="Agent Network", ) diff --git a/examples/preferencial_attachment/preferencial_attachment/agents.py b/examples/preferencial_attachment/preferencial_attachment/agents.py index 32fc850b..8c6d4b37 100644 --- a/examples/preferencial_attachment/preferencial_attachment/agents.py +++ b/examples/preferencial_attachment/preferencial_attachment/agents.py @@ -2,7 +2,6 @@ class NodeAgent(FixedAgent): - - def __init__(self,model,cell): + def __init__(self, model, cell): super().__init__(model) self.cell = cell diff --git a/examples/preferencial_attachment/preferencial_attachment/model.py b/examples/preferencial_attachment/preferencial_attachment/model.py index e57713bd..82caf7b9 100644 --- a/examples/preferencial_attachment/preferencial_attachment/model.py +++ b/examples/preferencial_attachment/preferencial_attachment/model.py @@ -7,12 +7,12 @@ def calculate_nodes_with_degree_1(model): - _ , degree = zip(*model.graph.degree()) - return sum(1 for deg in degree if deg==1) + _, degree = zip(*model.graph.degree()) + return sum(1 for deg in degree if deg == 1) -class AgentNetwork(Model): - def __init__(self,num=30,seed=42): +class AgentNetwork(Model): + def __init__(self, num=30, seed=42): """Initialize the model. Args: @@ -22,24 +22,23 @@ def __init__(self,num=30,seed=42): super().__init__(seed=seed) self.num = num self.random = seed - self.curr_node=1 + self.curr_node = 1 self.graph = nx.Graph() # Adding nodes to the graph for i in range(self.num): self.graph.add_node(i) - self.graph.add_edge(0,1) + self.graph.add_edge(0, 1) self.datacollector = DataCollector( { - "Degree": calculate_nodes_with_degree_1, + "Degree": calculate_nodes_with_degree_1, } ) - self.grid = Network(self.graph,capacity=1,random=self.random) - NodeAgent.create_agents(model=self,n=self.num,cell=list(self.grid.all_cells)) - + self.grid = Network(self.graph, capacity=1, random=self.random) + NodeAgent.create_agents(model=self, n=self.num, cell=list(self.grid.all_cells)) def step(self): self.curr_node += 1 @@ -48,13 +47,13 @@ def step(self): total_degree = sum(degree) # probabilities of connecting to an existing node - probabilities = [d/total_degree for d in degree] + probabilities = [d / total_degree for d in degree] # choose an existing node based on the computed probabilities chosen_node = np.random.choice(nodes, p=probabilities) # add the new node and connect it to the choosen node - self.graph.add_edge(chosen_node,self.curr_node) + self.graph.add_edge(chosen_node, self.curr_node) self.datacollector.collect(self) if self.steps >= self.num - 2: From 47c6f86194189e8961f7f622cbe5382517f84513 Mon Sep 17 00:00:00 2001 From: Spartan-71 Date: Mon, 14 Apr 2025 12:01:02 +0530 Subject: [PATCH 6/6] fix: imports --- .../preferencial_attachment/preferencial_attachment/agents.py | 2 +- .../preferencial_attachment/preferencial_attachment/model.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/preferencial_attachment/preferencial_attachment/agents.py b/examples/preferencial_attachment/preferencial_attachment/agents.py index 8c6d4b37..de33de2b 100644 --- a/examples/preferencial_attachment/preferencial_attachment/agents.py +++ b/examples/preferencial_attachment/preferencial_attachment/agents.py @@ -1,4 +1,4 @@ -from mesa.discrete_space import FixedAgent +from mesa.experimental.cell_space import FixedAgent class NodeAgent(FixedAgent): diff --git a/examples/preferencial_attachment/preferencial_attachment/model.py b/examples/preferencial_attachment/preferencial_attachment/model.py index 82caf7b9..17d43870 100644 --- a/examples/preferencial_attachment/preferencial_attachment/model.py +++ b/examples/preferencial_attachment/preferencial_attachment/model.py @@ -1,7 +1,7 @@ import networkx as nx import numpy as np from mesa import DataCollector, Model -from mesa.discrete_space import Network +from mesa.experimental.cell_space import Network from .agents import NodeAgent