我有一个由742个边和360个节点组成的图。
我想计算一些节点对之间的最大流量,并且它发生了,对于其中一些节点,nx.maximum_flow
以粘贴的错误结束,尽管两个相关节点之间存在路径。
知道是什么原因引起的吗?
感谢。
ValueError Traceback (most recent call last)
<ipython-input-186-6dae3501e3d0> in <module>()
1 #print(nx.shortest_path(G,source="Sink_0",target="node_32"))
----> 2 nx.maximum_flow(G, "Sink_0", "Aircraft2_32")
/Library/Python/2.7/site-packages/networkx/algorithms/flow/maxflow.pyc in maximum_flow(G, s, t, capacity, flow_func, **kwargs)
156 raise nx.NetworkXError("flow_func has to be callable.")
157
--> 158 R = flow_func(G, s, t, capacity=capacity, value_only=False, **kwargs)
159 flow_dict = build_flow_dict(G, R)
160
/Library/Python/2.7/site-packages/networkx/algorithms/flow/preflowpush.pyc in preflow_push(G, s, t, capacity, residual, global_relabel_freq, value_only)
420 """
421 R = preflow_push_impl(G, s, t, capacity, residual, global_relabel_freq,
--> 422 value_only)
423 R.graph['algorithm'] = 'preflow_push'
424 return R
/Library/Python/2.7/site-packages/networkx/algorithms/flow/preflowpush.pyc in preflow_push_impl(G, s, t, capacity, residual, global_relabel_freq, value_only)
279 break
280 u = next(iter(level.active))
--> 281 height = discharge(u, False)
282 if grt.is_reached():
283 # Global relabeling heuristic.
/Library/Python/2.7/site-packages/networkx/algorithms/flow/preflowpush.pyc in discharge(u, is_phase1)
156 # We have run off the end of the adjacency list, and there can
157 # be no more admissible edges. Relabel the node to create one.
--> 158 height = relabel(u)
159 if is_phase1 and height >= n - 1:
160 # Although the node is still active, with a height at least
/Library/Python/2.7/site-packages/networkx/algorithms/flow/preflowpush.pyc in relabel(u)
125 """
126 grt.add_work(len(R_succ[u]))
--> 127 return min(R_node[v]['height'] for v, attr in R_succ[u].items()
128 if attr['flow'] < attr['capacity']) + 1
129
ValueError: min() arg is an empty sequence