Return a maximum flow for a single-commodity flow problem.
Parameters : | G : NetworkX graph
s : node
t : node
capacity: string :
|
---|---|
Returns : | flow_dict : dictionary
|
Raises : | NetworkXError :
NetworkXUnbounded :
|
Examples
>>> import networkx as nx
>>> G = nx.DiGraph()
>>> G.add_edge('x','a', capacity=3.0)
>>> G.add_edge('x','b', capacity=1.0)
>>> G.add_edge('a','c', capacity=3.0)
>>> G.add_edge('b','c', capacity=5.0)
>>> G.add_edge('b','d', capacity=4.0)
>>> G.add_edge('d','e', capacity=2.0)
>>> G.add_edge('c','y', capacity=2.0)
>>> G.add_edge('e','y', capacity=3.0)
>>> F = nx.ford_fulkerson_flow(G, 'x', 'y')
>>> for u, v in G.edges_iter():
... print('(%s, %s) %.2f' % (u, v, F[u][v]))
...
(a, c) 2.00
(c, y) 2.00
(b, c) 0.00
(b, d) 1.00
(e, y) 1.00
(d, e) 1.00
(x, a) 2.00
(x, b) 1.00