Commit 3e996ab9 authored by Morten Knutsen's avatar Morten Knutsen
Browse files

remove all uses of in_edges() and out_edges(), deprecated in 0.99

parent e163e5a3
......@@ -64,7 +64,7 @@ class Model:
sum = 0
if not loads: loads = self.linkloads
if not G: G = self.graph
for e in G.in_edges(node):
for e in [(v,u) for (u,v) in G.edges() if u == node]:
sum += loads[e[1], e[0]]
return sum
......@@ -72,7 +72,7 @@ class Model:
sum = 0
if not loads: loads = self.linkloads
if not G: G = self.graph
for e in G.out_edges(node):
for e in G.edges(node):
sum += loads[e[0], e[1]]
return sum
......@@ -133,6 +133,7 @@ class Model:
#print " Finding nodes_and_paths (%s, %s) (%s secs)" % (u,v,time.time()-stime)
nodes, pathlist = self.nodes_and_paths_using_edge(u, v, G)
#print " Nodes: %s -- Pathlist: %s" % (nodes, pathlist)
#print " Done. (%s secs)" % (time.time()-stime)
partloads = {}
counts = {}
......@@ -287,7 +288,7 @@ class Model:
retinfo['degree'] = G.out_degree(node)
retinfo['links'] = map(lambda x: x[2]['l'] + \
" (" + str(int(x[2]['value'])) + ")",
G.out_edges(node))
G.edges(node))
retinfo['neighbors'] = G.neighbors(node)
retinfo['longest paths'] = self.get_max_cost_paths(nodes=[node])
retinfo['eccentricity'] = nx.eccentricity(G, node)
......@@ -713,7 +714,7 @@ class Simulation:
retinfo['degree'] = G.out_degree(node)
retinfo['links'] = map(lambda x: self.model.graph.get_edge(x[0], x[1])['l']\
+ " (" + str(int(x[2])) + ")",
G.out_edges(node))
G.edges(node))
retinfo['neighbors'] = G.neighbors(node)
retinfo['longest paths'] = self.get_max_cost_paths(nodes=[node])
retinfo['eccentricity'] = nx.eccentricity(G, node)
......
......@@ -127,7 +127,7 @@ def read_linkloads(G, host, url):
def calc_ratio(G, loads, u, v, discard_inverse=False, no_diff=False, exclude_edges=[]):
sum = 0
totload = loads[(u,v)]
for (u1,v1,d) in G.in_edges(u):
for (u1,v1,d) in [(v2, u2, d2) for (u2, v2, d2) in G.edges(data=True) if u2 == u]:
if (u1,v1) in exclude_edges:
#totload -= loads[(u1,v1)] * calc_ratio(G, loads, u,v)
continue
......@@ -151,7 +151,7 @@ def calc_ratio(G, loads, u, v, discard_inverse=False, no_diff=False, exclude_edg
def calc_contrib_ratio2(G, loads, u, v, discard_inverse=False, exclude_edges=[]):
sum = 0
for (u1,v1,d) in G.in_edges(v):
for (u1,v1,d) in [(v2, u2, d2) for (u2, v2, d2) in G.edges(data=True) if u2 == v]:
if (u1,v1) in exclude_edges: continue
if discard_inverse and (u1,v1) == (u,v): continue
sum += float(loads[(u1,v1)])
......@@ -165,7 +165,8 @@ def calc_contrib_ratio2(G, loads, u, v, discard_inverse=False, exclude_edges=[])
def calc_contrib_ratio(G, loads, u, v, discard_diff=False, exclude_edges=[]):
sum = 0
for (u1,v1,d) in G.in_edges(v):
for (u1,v1,d) in [(v2, u2, d2) for (u2, v2, d2) in G.edges(data=True) if u2 == v]:
if (u1,v1) in exclude_edges: continue
sum += float(loads[(u1,v1)])
print "Sum before diff:", sum
......@@ -187,10 +188,11 @@ def node_diff_in_out(G, loads, node, inverse=False, exclude_edges=[]):
sum_out = 0
sum_in = 0
for (u1,v1,d) in G.out_edges(node):
for (u1,v1,d) in G.edges(node, data=True):
if (u1,v1) in exclude_edges: continue
sum_out += loads[(u1,v1)]
for (u1,v1,d) in G.in_edges(node):
for (u1,v1,d) in [(v2, u2, d2) for (u2, v2, d2) in G.edges(data=True) if u2 == node]:
if (u1,v1) in exclude_edges: continue
sum_in += loads[(u1,v1)]
......
Supports Markdown
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