\HeaderA{max.flow}{Compute max flow for a directed graph}{max.flow}
\aliasA{edmunds.karp.max.flow}{max.flow}{edmunds.karp.max.flow}
\aliasA{push.relabel.max.flow}{max.flow}{push.relabel.max.flow}
\keyword{models}{max.flow}
\begin{Description}\relax
Compute max flow for a directed graph
\end{Description}
\begin{Usage}
\begin{verbatim}
edmunds.karp.max.flow(g, source, sink)
push.relabel.max.flow(g, source, sink)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{g}] an instance of the \code{graph} class with \code{edgemode}
\dQuote{directed}
\item[\code{source}] node name (character) or node number (int) for the source of the flow 
\item[\code{sink}] node name (character) or node number (int) for the sink of the flow 
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
Given a directed graph G=(V, E) of a single connected component with a vertex 
\code{source} and a vertex \code{sink}.  Each arc has a positive real valued 
capacity, currently it's equivalent to the weight of the arc.  The flow of the 
network is the net flow entering the vertex \code{sink}. The maximum flow 
problem is to determine the maximum possible value for the flow to the 
\code{sink} and the corresponding flow values for each arc. 
See documentation on these algorithms in Boost Graph Library for more details.
\end{Details}
\begin{Value}
A list of
\begin{ldescription}
\item[\code{maxflow}] the max flow from \code{source} to \code{sink} 
\item[\code{edges}] the nodes of the arcs with non-zero capacities
\item[\code{flows}] the flow values of the arcs with non-zero capacities
\end{ldescription}
\end{Value}
\begin{Author}\relax
Li Long <li.long@isb-sib.ch>
\end{Author}
\begin{References}\relax
Boost Graph Library by Siek et al.
\end{References}
\begin{SeeAlso}\relax
\code{\LinkA{minCut}{minCut}}, \code{\LinkA{edgeConnectivity}{edgeConnectivity}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
g <- fromGXL(file(system.file("XML/dijkex.gxl",package="RBGL"), open="r"))

ans1 <- edmunds.karp.max.flow(g, "B", "D")
ans2 <- edmunds.karp.max.flow(g, 3, 2)     # 3 and 2 equivalent to "C" and "B"

ans3 <- push.relabel.max.flow(g, 2, 4)     # 2 and 4 equivalent to "B" and "D"
ans4 <- push.relabel.max.flow(g, "C", "B")
\end{ExampleCode}
\end{Examples}

