networkx.algorithms.flow.build_residual_network¶
- build_residual_network(G, capacity)[source]¶
Build a residual network and initialize a zero flow.
The residual network
Rfrom an input graphGhas the same nodes asG.Ris a DiGraph that contains a pair of edges(u, v)and(v, u)iff(u, v)is not a self-loop, and at least one of(u, v)and(v, u)exists inG.For each edge
(u, v)inR,R[u][v]['capacity']is equal to the capacity of(u, v)inGif it exists inGor zero otherwise. If the capacity is infinite,R[u][v]['capacity']will have a high arbitrary finite value that does not affect the solution of the problem. This value is stored inR.graph['inf']. For each edge(u, v)inR,R[u][v]['flow']represents the flow function of(u, v)and satisfiesR[u][v]['flow'] == -R[v][u]['flow'].The flow value, defined as the total flow into
t, the sink, is stored inR.graph['flow_value']. Ifcutoffis not specified, reachability totusing only edges(u, v)such thatR[u][v]['flow'] < R[u][v]['capacity']induces a minimums-tcut.