Commit 98d8c1bc authored by Morten Knutsen's avatar Morten Knutsen
Browse files

Provide useful error output when capacity is missing or wrong.

Also, just return 0.0 for link utilization when we are missing
capacity information for the link and output a warning.
parent 8a4c06c3
......@@ -424,7 +424,13 @@ class Model:
return int(linkinfo['c'])
def get_link_utilization(self, u, v):
return self.get_out_link_load(u,v)/float(self.get_link_capacity(u,v))
utilz = self.get_out_link_load(u,v)/float(self.get_link_capacity(u,v))
except ZeroDivisionError:
print "Warning: Could not get link capacity for link:"
print "%s => %s" % (u,v)
utilz = 0.0
return utilz
def get_link_utilizations(self):
utils = {}
......@@ -244,8 +244,13 @@ class PlotUI:
edgecolors = [max(edge_cmap[(edges[i][0], edges[i][1])],
edge_cmap[(edges[i][1], edges[i][0])])
for i in range(len(edges))]
edgewidths = [PlotUI.edgewidths[edge_capa[(edges[i][0], edges[i][1])]]
for i in range(len(edges))]
edgewidths = [PlotUI.edgewidths[edge_capa[(edges[i][0], edges[i][1])]]
for i in range(len(edges))]
except KeyError:
print "Error: Unknown or missing capacity information provided to plot command"
self.edgec = nx.draw_networkx_edges(graph, pos=data['pos'],
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