We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Remove Sigma.js backend for network visualization
Reading #388, I conclude that Sigma.js is less featureful than D3.js. We should just stick to polishing the D3.js version.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `examples/virus_on_network/virus_on_network/server.py`
Content:
```
1 import math
2 
3 from mesa.visualization.ModularVisualization import ModularServer
4 from mesa.visualization.UserParam import UserSettableParameter
5 from mesa.visualization.modules import ChartModule
6 from mesa.visualization.modules import NetworkModule
7 from mesa.visualization.modules import TextElement
8 from .model import VirusOnNetwork, State, number_infected
9 
10 
11 def network_portrayal(G):
12     # The model ensures there is always 1 agent per node
13 
14     def node_color(agent):
15         return {State.INFECTED: "#FF0000", State.SUSCEPTIBLE: "#008000"}.get(
16             agent.state, "#808080"
17         )
18 
19     def edge_color(agent1, agent2):
20         if State.RESISTANT in (agent1.state, agent2.state):
21             return "#000000"
22         return "#e8e8e8"
23 
24     def edge_width(agent1, agent2):
25         if State.RESISTANT in (agent1.state, agent2.state):
26             return 3
27         return 2
28 
29     def get_agents(source, target):
30         return G.nodes[source]["agent"][0], G.nodes[target]["agent"][0]
31 
32     portrayal = dict()
33     portrayal["nodes"] = [
34         {
35             "size": 6,
36             "color": node_color(agents[0]),
37             "tooltip": f"id: {agents[0].unique_id}<br>state: {agents[0].state.name}",
38         }
39         for (_, agents) in G.nodes.data("agent")
40     ]
41 
42     portrayal["edges"] = [
43         {
44             "source": source,
45             "target": target,
46             "color": edge_color(*get_agents(source, target)),
47             "width": edge_width(*get_agents(source, target)),
48         }
49         for (source, target) in G.edges
50     ]
51 
52     return portrayal
53 
54 
55 network = NetworkModule(network_portrayal, 500, 500, library="d3")
56 chart = ChartModule(
57     [
58         {"Label": "Infected", "Color": "#FF0000"},
59         {"Label": "Susceptible", "Color": "#008000"},
60         {"Label": "Resistant", "Color": "#808080"},
61     ]
62 )
63 
64 
65 class MyTextElement(TextElement):
66     def render(self, model):
67         ratio = model.resistant_susceptible_ratio()
68         ratio_text = "&infin;" if ratio is math.inf else f"{ratio:.2f}"
69         infected_text = str(number_infected(model))
70 
71         return "Resistant/Susceptible Ratio: {}<br>Infected Remaining: {}".format(
72             ratio_text, infected_text
73         )
74 
75 
76 model_params = {
77     "num_nodes": UserSettableParameter(
78         "slider",
79         "Number of agents",
80         10,
81         10,
82         100,
83         1,
84         description="Choose how many agents to include in the model",
85     ),
86     "avg_node_degree": UserSettableParameter(
87         "slider", "Avg Node Degree", 3, 3, 8, 1, description="Avg Node Degree"
88     ),
89     "initial_outbreak_size": UserSettableParameter(
90         "slider",
91         "Initial Outbreak Size",
92         1,
93         1,
94         10,
95         1,
96         description="Initial Outbreak Size",
97     ),
98     "virus_spread_chance": UserSettableParameter(
99         "slider",
100         "Virus Spread Chance",
101         0.4,
102         0.0,
103         1.0,
104         0.1,
105         description="Probability that susceptible neighbor will be infected",
106     ),
107     "virus_check_frequency": UserSettableParameter(
108         "slider",
109         "Virus Check Frequency",
110         0.4,
111         0.0,
112         1.0,
113         0.1,
114         description="Frequency the nodes check whether they are infected by " "a virus",
115     ),
116     "recovery_chance": UserSettableParameter(
117         "slider",
118         "Recovery Chance",
119         0.3,
120         0.0,
121         1.0,
122         0.1,
123         description="Probability that the virus will be removed",
124     ),
125     "gain_resistance_chance": UserSettableParameter(
126         "slider",
127         "Gain Resistance Chance",
128         0.5,
129         0.0,
130         1.0,
131         0.1,
132         description="Probability that a recovered agent will become "
133         "resistant to this virus in the future",
134     ),
135 }
136 
137 server = ModularServer(
138     VirusOnNetwork, [network, MyTextElement(), chart], "Virus Model", model_params
139 )
140 server.port = 8521
141
```

Path: `examples/boltzmann_wealth_model_network/boltzmann_wealth_model_network/server.py`
Content:
```
1 from mesa.visualization.ModularVisualization import ModularServer
2 from mesa.visualization.UserParam import UserSettableParameter
3 from mesa.visualization.modules import ChartModule
4 from mesa.visualization.modules import NetworkModule
5 from .model import BoltzmannWealthModelNetwork
6 
7 
8 def network_portrayal(G):
9     # The model ensures there is 0 or 1 agent per node
10 
11     portrayal = dict()
12     portrayal["nodes"] = [
13         {
14             "id": node_id,
15             "size": 3 if agents else 1,
16             "color": "#CC0000" if not agents or agents[0].wealth == 0 else "#007959",
17             "label": None
18             if not agents
19             else f"Agent:{agents[0].unique_id} Wealth:{agents[0].wealth}",
20         }
21         for (node_id, agents) in G.nodes.data("agent")
22     ]
23 
24     portrayal["edges"] = [
25         {"id": edge_id, "source": source, "target": target, "color": "#000000"}
26         for edge_id, (source, target) in enumerate(G.edges)
27     ]
28 
29     return portrayal
30 
31 
32 grid = NetworkModule(network_portrayal, 500, 500, library="sigma")
33 chart = ChartModule(
34     [{"Label": "Gini", "Color": "Black"}], data_collector_name="datacollector"
35 )
36 
37 model_params = {
38     "num_agents": UserSettableParameter(
39         "slider",
40         "Number of agents",
41         7,
42         2,
43         10,
44         1,
45         description="Choose how many agents to include in the model",
46     ),
47     "num_nodes": UserSettableParameter(
48         "slider",
49         "Number of nodes",
50         10,
51         3,
52         12,
53         1,
54         description="Choose how many nodes to include in the model, with at "
55         "least the same number of agents",
56     ),
57 }
58 
59 server = ModularServer(
60     BoltzmannWealthModelNetwork, [grid, chart], "Money Model", model_params
61 )
62 server.port = 8521
63
```

Path: `mesa/visualization/modules/NetworkVisualization.py`
Content:
```
1 """
2 Network Visualization Module
3 ============
4 
5 Module for rendering the network, using [sigma.js](http://sigmajs.org/) or [d3.js](https://d3js.org/) frameworks.
6 
7 """
8 from mesa.visualization.ModularVisualization import VisualizationElement, D3_JS_FILE
9 
10 
11 class NetworkModule(VisualizationElement):
12     package_includes = []
13 
14     def __init__(
15         self, portrayal_method, canvas_height=500, canvas_width=500, library="sigma"
16     ):
17         library_types = ["sigma", "d3"]
18         if library not in library_types:
19             raise ValueError(
20                 f"Invalid javascript library type. Expected one of: {library_types}"
21             )
22 
23         NetworkModule.package_includes = (
24             ["NetworkModule_sigma.js", "sigma.min.js"]
25             if library == "sigma"
26             else ["NetworkModule_d3.js", D3_JS_FILE]
27         )
28 
29         self.portrayal_method = portrayal_method
30         self.canvas_height = canvas_height
31         self.canvas_width = canvas_width
32         new_element = f"new NetworkModule({self.canvas_width}, {self.canvas_height})"
33         self.js_code = "elements.push(" + new_element + ");"
34 
35     def render(self, model):
36         return self.portrayal_method(model.G)
37
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/examples/boltzmann_wealth_model_network/boltzmann_wealth_model_network/server.py b/examples/boltzmann_wealth_model_network/boltzmann_wealth_model_network/server.py
--- a/examples/boltzmann_wealth_model_network/boltzmann_wealth_model_network/server.py
+++ b/examples/boltzmann_wealth_model_network/boltzmann_wealth_model_network/server.py
@@ -29,7 +29,7 @@
     return portrayal
 
 
-grid = NetworkModule(network_portrayal, 500, 500, library="sigma")
+grid = NetworkModule(network_portrayal, 500, 500)
 chart = ChartModule(
     [{"Label": "Gini", "Color": "Black"}], data_collector_name="datacollector"
 )
diff --git a/examples/virus_on_network/virus_on_network/server.py b/examples/virus_on_network/virus_on_network/server.py
--- a/examples/virus_on_network/virus_on_network/server.py
+++ b/examples/virus_on_network/virus_on_network/server.py
@@ -52,7 +52,7 @@
     return portrayal
 
 
-network = NetworkModule(network_portrayal, 500, 500, library="d3")
+network = NetworkModule(network_portrayal, 500, 500)
 chart = ChartModule(
     [
         {"Label": "Infected", "Color": "#FF0000"},
diff --git a/mesa/visualization/modules/NetworkVisualization.py b/mesa/visualization/modules/NetworkVisualization.py
--- a/mesa/visualization/modules/NetworkVisualization.py
+++ b/mesa/visualization/modules/NetworkVisualization.py
@@ -2,7 +2,7 @@
 Network Visualization Module
 ============
 
-Module for rendering the network, using [sigma.js](http://sigmajs.org/) or [d3.js](https://d3js.org/) frameworks.
+Module for rendering the network, using [d3.js](https://d3js.org/) framework.
 
 """
 from mesa.visualization.ModularVisualization import VisualizationElement, D3_JS_FILE
@@ -12,19 +12,12 @@
     package_includes = []
 
     def __init__(
-        self, portrayal_method, canvas_height=500, canvas_width=500, library="sigma"
+        self,
+        portrayal_method,
+        canvas_height=500,
+        canvas_width=500,
     ):
-        library_types = ["sigma", "d3"]
-        if library not in library_types:
-            raise ValueError(
-                f"Invalid javascript library type. Expected one of: {library_types}"
-            )
-
-        NetworkModule.package_includes = (
-            ["NetworkModule_sigma.js", "sigma.min.js"]
-            if library == "sigma"
-            else ["NetworkModule_d3.js", D3_JS_FILE]
-        )
+        NetworkModule.package_includes = ["NetworkModule_d3.js", D3_JS_FILE]
 
         self.portrayal_method = portrayal_method
         self.canvas_height = canvas_height

{"golden_diff": "diff --git a/examples/boltzmann_wealth_model_network/boltzmann_wealth_model_network/server.py b/examples/boltzmann_wealth_model_network/boltzmann_wealth_model_network/server.py\n--- a/examples/boltzmann_wealth_model_network/boltzmann_wealth_model_network/server.py\n+++ b/examples/boltzmann_wealth_model_network/boltzmann_wealth_model_network/server.py\n@@ -29,7 +29,7 @@\n     return portrayal\n \n \n-grid = NetworkModule(network_portrayal, 500, 500, library=\"sigma\")\n+grid = NetworkModule(network_portrayal, 500, 500)\n chart = ChartModule(\n     [{\"Label\": \"Gini\", \"Color\": \"Black\"}], data_collector_name=\"datacollector\"\n )\ndiff --git a/examples/virus_on_network/virus_on_network/server.py b/examples/virus_on_network/virus_on_network/server.py\n--- a/examples/virus_on_network/virus_on_network/server.py\n+++ b/examples/virus_on_network/virus_on_network/server.py\n@@ -52,7 +52,7 @@\n     return portrayal\n \n \n-network = NetworkModule(network_portrayal, 500, 500, library=\"d3\")\n+network = NetworkModule(network_portrayal, 500, 500)\n chart = ChartModule(\n     [\n         {\"Label\": \"Infected\", \"Color\": \"#FF0000\"},\ndiff --git a/mesa/visualization/modules/NetworkVisualization.py b/mesa/visualization/modules/NetworkVisualization.py\n--- a/mesa/visualization/modules/NetworkVisualization.py\n+++ b/mesa/visualization/modules/NetworkVisualization.py\n@@ -2,7 +2,7 @@\n Network Visualization Module\n ============\n \n-Module for rendering the network, using [sigma.js](http://sigmajs.org/) or [d3.js](https://d3js.org/) frameworks.\n+Module for rendering the network, using [d3.js](https://d3js.org/) framework.\n \n \"\"\"\n from mesa.visualization.ModularVisualization import VisualizationElement, D3_JS_FILE\n@@ -12,19 +12,12 @@\n     package_includes = []\n \n     def __init__(\n-        self, portrayal_method, canvas_height=500, canvas_width=500, library=\"sigma\"\n+        self,\n+        portrayal_method,\n+        canvas_height=500,\n+        canvas_width=500,\n     ):\n-        library_types = [\"sigma\", \"d3\"]\n-        if library not in library_types:\n-            raise ValueError(\n-                f\"Invalid javascript library type. Expected one of: {library_types}\"\n-            )\n-\n-        NetworkModule.package_includes = (\n-            [\"NetworkModule_sigma.js\", \"sigma.min.js\"]\n-            if library == \"sigma\"\n-            else [\"NetworkModule_d3.js\", D3_JS_FILE]\n-        )\n+        NetworkModule.package_includes = [\"NetworkModule_d3.js\", D3_JS_FILE]\n \n         self.portrayal_method = portrayal_method\n         self.canvas_height = canvas_height\n", "issue": "Remove Sigma.js backend for network visualization\nReading #388, I conclude that Sigma.js is less featureful than D3.js. We should just stick to polishing the D3.js version.\n", "before_files": [{"content": "import math\n\nfrom mesa.visualization.ModularVisualization import ModularServer\nfrom mesa.visualization.UserParam import UserSettableParameter\nfrom mesa.visualization.modules import ChartModule\nfrom mesa.visualization.modules import NetworkModule\nfrom mesa.visualization.modules import TextElement\nfrom .model import VirusOnNetwork, State, number_infected\n\n\ndef network_portrayal(G):\n    # The model ensures there is always 1 agent per node\n\n    def node_color(agent):\n        return {State.INFECTED: \"#FF0000\", State.SUSCEPTIBLE: \"#008000\"}.get(\n            agent.state, \"#808080\"\n        )\n\n    def edge_color(agent1, agent2):\n        if State.RESISTANT in (agent1.state, agent2.state):\n            return \"#000000\"\n        return \"#e8e8e8\"\n\n    def edge_width(agent1, agent2):\n        if State.RESISTANT in (agent1.state, agent2.state):\n            return 3\n        return 2\n\n    def get_agents(source, target):\n        return G.nodes[source][\"agent\"][0], G.nodes[target][\"agent\"][0]\n\n    portrayal = dict()\n    portrayal[\"nodes\"] = [\n        {\n            \"size\": 6,\n            \"color\": node_color(agents[0]),\n            \"tooltip\": f\"id: {agents[0].unique_id}<br>state: {agents[0].state.name}\",\n        }\n        for (_, agents) in G.nodes.data(\"agent\")\n    ]\n\n    portrayal[\"edges\"] = [\n        {\n            \"source\": source,\n            \"target\": target,\n            \"color\": edge_color(*get_agents(source, target)),\n            \"width\": edge_width(*get_agents(source, target)),\n        }\n        for (source, target) in G.edges\n    ]\n\n    return portrayal\n\n\nnetwork = NetworkModule(network_portrayal, 500, 500, library=\"d3\")\nchart = ChartModule(\n    [\n        {\"Label\": \"Infected\", \"Color\": \"#FF0000\"},\n        {\"Label\": \"Susceptible\", \"Color\": \"#008000\"},\n        {\"Label\": \"Resistant\", \"Color\": \"#808080\"},\n    ]\n)\n\n\nclass MyTextElement(TextElement):\n    def render(self, model):\n        ratio = model.resistant_susceptible_ratio()\n        ratio_text = \"&infin;\" if ratio is math.inf else f\"{ratio:.2f}\"\n        infected_text = str(number_infected(model))\n\n        return \"Resistant/Susceptible Ratio: {}<br>Infected Remaining: {}\".format(\n            ratio_text, infected_text\n        )\n\n\nmodel_params = {\n    \"num_nodes\": UserSettableParameter(\n        \"slider\",\n        \"Number of agents\",\n        10,\n        10,\n        100,\n        1,\n        description=\"Choose how many agents to include in the model\",\n    ),\n    \"avg_node_degree\": UserSettableParameter(\n        \"slider\", \"Avg Node Degree\", 3, 3, 8, 1, description=\"Avg Node Degree\"\n    ),\n    \"initial_outbreak_size\": UserSettableParameter(\n        \"slider\",\n        \"Initial Outbreak Size\",\n        1,\n        1,\n        10,\n        1,\n        description=\"Initial Outbreak Size\",\n    ),\n    \"virus_spread_chance\": UserSettableParameter(\n        \"slider\",\n        \"Virus Spread Chance\",\n        0.4,\n        0.0,\n        1.0,\n        0.1,\n        description=\"Probability that susceptible neighbor will be infected\",\n    ),\n    \"virus_check_frequency\": UserSettableParameter(\n        \"slider\",\n        \"Virus Check Frequency\",\n        0.4,\n        0.0,\n        1.0,\n        0.1,\n        description=\"Frequency the nodes check whether they are infected by \" \"a virus\",\n    ),\n    \"recovery_chance\": UserSettableParameter(\n        \"slider\",\n        \"Recovery Chance\",\n        0.3,\n        0.0,\n        1.0,\n        0.1,\n        description=\"Probability that the virus will be removed\",\n    ),\n    \"gain_resistance_chance\": UserSettableParameter(\n        \"slider\",\n        \"Gain Resistance Chance\",\n        0.5,\n        0.0,\n        1.0,\n        0.1,\n        description=\"Probability that a recovered agent will become \"\n        \"resistant to this virus in the future\",\n    ),\n}\n\nserver = ModularServer(\n    VirusOnNetwork, [network, MyTextElement(), chart], \"Virus Model\", model_params\n)\nserver.port = 8521\n", "path": "examples/virus_on_network/virus_on_network/server.py"}, {"content": "from mesa.visualization.ModularVisualization import ModularServer\nfrom mesa.visualization.UserParam import UserSettableParameter\nfrom mesa.visualization.modules import ChartModule\nfrom mesa.visualization.modules import NetworkModule\nfrom .model import BoltzmannWealthModelNetwork\n\n\ndef network_portrayal(G):\n    # The model ensures there is 0 or 1 agent per node\n\n    portrayal = dict()\n    portrayal[\"nodes\"] = [\n        {\n            \"id\": node_id,\n            \"size\": 3 if agents else 1,\n            \"color\": \"#CC0000\" if not agents or agents[0].wealth == 0 else \"#007959\",\n            \"label\": None\n            if not agents\n            else f\"Agent:{agents[0].unique_id} Wealth:{agents[0].wealth}\",\n        }\n        for (node_id, agents) in G.nodes.data(\"agent\")\n    ]\n\n    portrayal[\"edges\"] = [\n        {\"id\": edge_id, \"source\": source, \"target\": target, \"color\": \"#000000\"}\n        for edge_id, (source, target) in enumerate(G.edges)\n    ]\n\n    return portrayal\n\n\ngrid = NetworkModule(network_portrayal, 500, 500, library=\"sigma\")\nchart = ChartModule(\n    [{\"Label\": \"Gini\", \"Color\": \"Black\"}], data_collector_name=\"datacollector\"\n)\n\nmodel_params = {\n    \"num_agents\": UserSettableParameter(\n        \"slider\",\n        \"Number of agents\",\n        7,\n        2,\n        10,\n        1,\n        description=\"Choose how many agents to include in the model\",\n    ),\n    \"num_nodes\": UserSettableParameter(\n        \"slider\",\n        \"Number of nodes\",\n        10,\n        3,\n        12,\n        1,\n        description=\"Choose how many nodes to include in the model, with at \"\n        \"least the same number of agents\",\n    ),\n}\n\nserver = ModularServer(\n    BoltzmannWealthModelNetwork, [grid, chart], \"Money Model\", model_params\n)\nserver.port = 8521\n", "path": "examples/boltzmann_wealth_model_network/boltzmann_wealth_model_network/server.py"}, {"content": "\"\"\"\nNetwork Visualization Module\n============\n\nModule for rendering the network, using [sigma.js](http://sigmajs.org/) or [d3.js](https://d3js.org/) frameworks.\n\n\"\"\"\nfrom mesa.visualization.ModularVisualization import VisualizationElement, D3_JS_FILE\n\n\nclass NetworkModule(VisualizationElement):\n    package_includes = []\n\n    def __init__(\n        self, portrayal_method, canvas_height=500, canvas_width=500, library=\"sigma\"\n    ):\n        library_types = [\"sigma\", \"d3\"]\n        if library not in library_types:\n            raise ValueError(\n                f\"Invalid javascript library type. Expected one of: {library_types}\"\n            )\n\n        NetworkModule.package_includes = (\n            [\"NetworkModule_sigma.js\", \"sigma.min.js\"]\n            if library == \"sigma\"\n            else [\"NetworkModule_d3.js\", D3_JS_FILE]\n        )\n\n        self.portrayal_method = portrayal_method\n        self.canvas_height = canvas_height\n        self.canvas_width = canvas_width\n        new_element = f\"new NetworkModule({self.canvas_width}, {self.canvas_height})\"\n        self.js_code = \"elements.push(\" + new_element + \");\"\n\n    def render(self, model):\n        return self.portrayal_method(model.G)\n", "path": "mesa/visualization/modules/NetworkVisualization.py"}], "after_files": [{"content": "import math\n\nfrom mesa.visualization.ModularVisualization import ModularServer\nfrom mesa.visualization.UserParam import UserSettableParameter\nfrom mesa.visualization.modules import ChartModule\nfrom mesa.visualization.modules import NetworkModule\nfrom mesa.visualization.modules import TextElement\nfrom .model import VirusOnNetwork, State, number_infected\n\n\ndef network_portrayal(G):\n    # The model ensures there is always 1 agent per node\n\n    def node_color(agent):\n        return {State.INFECTED: \"#FF0000\", State.SUSCEPTIBLE: \"#008000\"}.get(\n            agent.state, \"#808080\"\n        )\n\n    def edge_color(agent1, agent2):\n        if State.RESISTANT in (agent1.state, agent2.state):\n            return \"#000000\"\n        return \"#e8e8e8\"\n\n    def edge_width(agent1, agent2):\n        if State.RESISTANT in (agent1.state, agent2.state):\n            return 3\n        return 2\n\n    def get_agents(source, target):\n        return G.nodes[source][\"agent\"][0], G.nodes[target][\"agent\"][0]\n\n    portrayal = dict()\n    portrayal[\"nodes\"] = [\n        {\n            \"size\": 6,\n            \"color\": node_color(agents[0]),\n            \"tooltip\": f\"id: {agents[0].unique_id}<br>state: {agents[0].state.name}\",\n        }\n        for (_, agents) in G.nodes.data(\"agent\")\n    ]\n\n    portrayal[\"edges\"] = [\n        {\n            \"source\": source,\n            \"target\": target,\n            \"color\": edge_color(*get_agents(source, target)),\n            \"width\": edge_width(*get_agents(source, target)),\n        }\n        for (source, target) in G.edges\n    ]\n\n    return portrayal\n\n\nnetwork = NetworkModule(network_portrayal, 500, 500)\nchart = ChartModule(\n    [\n        {\"Label\": \"Infected\", \"Color\": \"#FF0000\"},\n        {\"Label\": \"Susceptible\", \"Color\": \"#008000\"},\n        {\"Label\": \"Resistant\", \"Color\": \"#808080\"},\n    ]\n)\n\n\nclass MyTextElement(TextElement):\n    def render(self, model):\n        ratio = model.resistant_susceptible_ratio()\n        ratio_text = \"&infin;\" if ratio is math.inf else f\"{ratio:.2f}\"\n        infected_text = str(number_infected(model))\n\n        return \"Resistant/Susceptible Ratio: {}<br>Infected Remaining: {}\".format(\n            ratio_text, infected_text\n        )\n\n\nmodel_params = {\n    \"num_nodes\": UserSettableParameter(\n        \"slider\",\n        \"Number of agents\",\n        10,\n        10,\n        100,\n        1,\n        description=\"Choose how many agents to include in the model\",\n    ),\n    \"avg_node_degree\": UserSettableParameter(\n        \"slider\", \"Avg Node Degree\", 3, 3, 8, 1, description=\"Avg Node Degree\"\n    ),\n    \"initial_outbreak_size\": UserSettableParameter(\n        \"slider\",\n        \"Initial Outbreak Size\",\n        1,\n        1,\n        10,\n        1,\n        description=\"Initial Outbreak Size\",\n    ),\n    \"virus_spread_chance\": UserSettableParameter(\n        \"slider\",\n        \"Virus Spread Chance\",\n        0.4,\n        0.0,\n        1.0,\n        0.1,\n        description=\"Probability that susceptible neighbor will be infected\",\n    ),\n    \"virus_check_frequency\": UserSettableParameter(\n        \"slider\",\n        \"Virus Check Frequency\",\n        0.4,\n        0.0,\n        1.0,\n        0.1,\n        description=\"Frequency the nodes check whether they are infected by \" \"a virus\",\n    ),\n    \"recovery_chance\": UserSettableParameter(\n        \"slider\",\n        \"Recovery Chance\",\n        0.3,\n        0.0,\n        1.0,\n        0.1,\n        description=\"Probability that the virus will be removed\",\n    ),\n    \"gain_resistance_chance\": UserSettableParameter(\n        \"slider\",\n        \"Gain Resistance Chance\",\n        0.5,\n        0.0,\n        1.0,\n        0.1,\n        description=\"Probability that a recovered agent will become \"\n        \"resistant to this virus in the future\",\n    ),\n}\n\nserver = ModularServer(\n    VirusOnNetwork, [network, MyTextElement(), chart], \"Virus Model\", model_params\n)\nserver.port = 8521\n", "path": "examples/virus_on_network/virus_on_network/server.py"}, {"content": "from mesa.visualization.ModularVisualization import ModularServer\nfrom mesa.visualization.UserParam import UserSettableParameter\nfrom mesa.visualization.modules import ChartModule\nfrom mesa.visualization.modules import NetworkModule\nfrom .model import BoltzmannWealthModelNetwork\n\n\ndef network_portrayal(G):\n    # The model ensures there is 0 or 1 agent per node\n\n    portrayal = dict()\n    portrayal[\"nodes\"] = [\n        {\n            \"id\": node_id,\n            \"size\": 3 if agents else 1,\n            \"color\": \"#CC0000\" if not agents or agents[0].wealth == 0 else \"#007959\",\n            \"label\": None\n            if not agents\n            else f\"Agent:{agents[0].unique_id} Wealth:{agents[0].wealth}\",\n        }\n        for (node_id, agents) in G.nodes.data(\"agent\")\n    ]\n\n    portrayal[\"edges\"] = [\n        {\"id\": edge_id, \"source\": source, \"target\": target, \"color\": \"#000000\"}\n        for edge_id, (source, target) in enumerate(G.edges)\n    ]\n\n    return portrayal\n\n\ngrid = NetworkModule(network_portrayal, 500, 500)\nchart = ChartModule(\n    [{\"Label\": \"Gini\", \"Color\": \"Black\"}], data_collector_name=\"datacollector\"\n)\n\nmodel_params = {\n    \"num_agents\": UserSettableParameter(\n        \"slider\",\n        \"Number of agents\",\n        7,\n        2,\n        10,\n        1,\n        description=\"Choose how many agents to include in the model\",\n    ),\n    \"num_nodes\": UserSettableParameter(\n        \"slider\",\n        \"Number of nodes\",\n        10,\n        3,\n        12,\n        1,\n        description=\"Choose how many nodes to include in the model, with at \"\n        \"least the same number of agents\",\n    ),\n}\n\nserver = ModularServer(\n    BoltzmannWealthModelNetwork, [grid, chart], \"Money Model\", model_params\n)\nserver.port = 8521\n", "path": "examples/boltzmann_wealth_model_network/boltzmann_wealth_model_network/server.py"}, {"content": "\"\"\"\nNetwork Visualization Module\n============\n\nModule for rendering the network, using [d3.js](https://d3js.org/) framework.\n\n\"\"\"\nfrom mesa.visualization.ModularVisualization import VisualizationElement, D3_JS_FILE\n\n\nclass NetworkModule(VisualizationElement):\n    package_includes = []\n\n    def __init__(\n        self,\n        portrayal_method,\n        canvas_height=500,\n        canvas_width=500,\n    ):\n        NetworkModule.package_includes = [\"NetworkModule_d3.js\", D3_JS_FILE]\n\n        self.portrayal_method = portrayal_method\n        self.canvas_height = canvas_height\n        self.canvas_width = canvas_width\n        new_element = f\"new NetworkModule({self.canvas_width}, {self.canvas_height})\"\n        self.js_code = \"elements.push(\" + new_element + \");\"\n\n    def render(self, model):\n        return self.portrayal_method(model.G)\n", "path": "mesa/visualization/modules/NetworkVisualization.py"}]}