Commit 6677f6f7 authored by Morten Knutsen's avatar Morten Knutsen
Browse files

Make networkx usage compatible with newer versions, while retaining old support.

parent 5cbf08be
......@@ -86,8 +86,8 @@ class MetricShell(Cmd):
difflen = nx.average_shortest_path_length(self.simulation.graph)\
- nx.average_shortest_path_length(self.model.G)
components = nx.connected_component_subgraphs(
self.simulation.graph.to_undirected())
components = list(nx.connected_component_subgraphs(
self.simulation.graph.to_undirected()))
cnodes = 0
if len(components) > 1:
cnodes = sum([len(g.nodes()) for g in components[1:]])
......
......@@ -607,7 +607,7 @@ class Model:
self.betweenness = nx.load_centrality(self.G, weight='weight')
else:
self.betweenness = nx.load_centrality(self.G, weighted_edges=True)
self.edge_betweenness = nx.edge_betweenness(self.G, True, True)
self.edge_betweenness = nx.edge_betweenness(self.G, normalized=True, weight=True)
def _refresh_all_paths(self):
for node in self.G:
......@@ -1902,7 +1902,7 @@ class Simulation:
self.betweenness = nx.load_centrality(self.graph, weight='weight')
else:
self.betweenness = nx.load_centrality(self.graph, weighted_edges=True)
self.edge_betweenness = nx.edge_betweenness(self.graph, True, True)
self.edge_betweenness = nx.edge_betweenness(self.graph, normalized=True, weight=True)
def _refresh_effects(self, OG=None, NG=None):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment