def generate_path(self, topo, flow, link_caps):
try:
shortest_paths = [p for p in topo.get_shortest_paths(flow.src, flow.dst)]
except nx.exception.NetworkXNoPath:
self.log.debug("No shortest path for (%d, %d)" % (flow.src, flow.dst))
return False
for path in shortest_paths:
if not self.check_capacity(topo, path, link_caps, flow.vol, flow.reversed_vol):
continue
else:
self.allocate_link_cap(path, link_caps, flow.vol, flow.reversed_vol)
flow.path = path
break
return flow.path, None
评论列表
文章目录