EVOLUTION-MANAGER
Edit File: max_flow.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Maximum flow in a graph</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for max_flow {igraph}"><tr><td>max_flow {igraph}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Maximum flow in a graph</h2> <h3>Description</h3> <p>In a graph where each edge has a given flow capacity the maximal flow between two vertices is calculated. </p> <h3>Usage</h3> <pre> max_flow(graph, source, target, capacity = NULL) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>graph</code></td> <td> <p>The input graph.</p> </td></tr> <tr valign="top"><td><code>source</code></td> <td> <p>The id of the source vertex.</p> </td></tr> <tr valign="top"><td><code>target</code></td> <td> <p>The id of the target vertex (sometimes also called sink).</p> </td></tr> <tr valign="top"><td><code>capacity</code></td> <td> <p>Vector giving the capacity of the edges. If this is <code>NULL</code> (the default) then the <code>capacity</code> edge attribute is used. Note that the <code>weight</code> edge attribute is not used by this function.</p> </td></tr> </table> <h3>Details</h3> <p><code>max_flow</code> calculates the maximum flow between two vertices in a weighted (ie. valued) graph. A flow from <code>source</code> to <code>target</code> is an assignment of non-negative real numbers to the edges of the graph, satisfying two properties: (1) for each edge the flow (ie. the assigned number) is not more than the capacity of the edge (the <code>capacity</code> parameter or edge attribute), (2) for every vertex, except the source and the target the incoming flow is the same as the outgoing flow. The value of the flow is the incoming flow of the <code>target</code> vertex. The maximum flow is the flow of maximum value. </p> <h3>Value</h3> <p>A named list with components: </p> <table summary="R valueblock"> <tr valign="top"><td><code>value</code></td> <td> <p>A numeric scalar, the value of the maximum flow.</p> </td></tr> <tr valign="top"><td><code>flow</code></td> <td> <p>A numeric vector, the flow itself, one entry for each edge. For undirected graphs this entry is bit trickier, since for these the flow direction is not predetermined by the edge direction. For these graphs the elements of the this vector can be negative, this means that the flow goes from the bigger vertex id to the smaller one. Positive values mean that the flow goes from the smaller vertex id to the bigger one.</p> </td></tr> <tr valign="top"><td><code>cut</code></td> <td> <p>A numeric vector of edge ids, the minimum cut corresponding to the maximum flow.</p> </td></tr> <tr valign="top"><td><code>partition1</code></td> <td> <p>A numeric vector of vertex ids, the vertices in the first partition of the minimum cut corresponding to the maximum flow.</p> </td></tr> <tr valign="top"><td><code>partition2</code></td> <td> <p>A numeric vector of vertex ids, the vertices in the second partition of the minimum cut corresponding to the maximum flow.</p> </td></tr> <tr valign="top"><td><code>stats</code></td> <td> <p>A list with some statistics from the push-relabel algorithm. Five integer values currently: <code>nopush</code> is the number of push operations, <code>norelabel</code> the number of relabelings, <code>nogap</code> is the number of times the gap heuristics was used, <code>nogapnodes</code> is the total number of gap nodes omitted because of the gap heuristics and <code>nobfs</code> is the number of times a global breadth-first-search update was performed to assign better height (=distance) values to the vertices.</p> </td></tr> </table> <h3>References</h3> <p>A. V. Goldberg and R. E. Tarjan: A New Approach to the Maximum Flow Problem <em>Journal of the ACM</em> 35:921-940, 1988. </p> <h3>See Also</h3> <p><code><a href="min_cut.html">min_cut</a></code> for minimum cut calculations, <code><a href="distances.html">distances</a></code>, <code><a href="edge_connectivity.html">edge_connectivity</a></code>, <code><a href="vertex_connectivity.html">vertex_connectivity</a></code> </p> <h3>Examples</h3> <pre> E <- rbind( c(1,3,3), c(3,4,1), c(4,2,2), c(1,5,1), c(5,6,2), c(6,2,10)) colnames(E) <- c("from", "to", "capacity") g1 <- graph_from_data_frame(as.data.frame(E)) max_flow(g1, source=V(g1)["1"], target=V(g1)["2"]) </pre> <hr /><div style="text-align: center;">[Package <em>igraph</em> version 1.3.5 <a href="00Index.html">Index</a>]</div> </body></html>