GraphTheory
MaxFlow
compute optimal value for max flow problem
Calling Sequence
Parameters
Description
Examples
MaxFlow(G, s, t)
G
-
weighted graph
s
vertex of the graph (source)
t
vertex of the graph (sink)
The MaxFlow command returns the optimal value for the max flow problem along with an optimal flow (as a Matrix).
The algorithm used is the Push-Relabel (Push-Preflow) algorithm of Goldberg et al. (see Introduction to Algorithms, Cormen, Leiserson, Rivest, 2nd edition). The complexity is O⁡n2⁢m where n=|V| is the number of vertices of G and m=|E| is the number of edges.
with⁡GraphTheory:
A ≔ Matrix⁡0,1,0,4,0,0,0,0,1,0,3,0,0,1,0,0,0,1,0,0,3,0,1,0,0,0,0,1,0,4,0,0,0,0,0,0
A≔010400001030010001003010000104000000
N ≔ Digraph⁡A,weighted
N≔Graph 1: a directed weighted graph with 6 vertices and 10 arc(s)
IsNetwork⁡N
1,6
DrawNetwork⁡N
MaxFlow⁡N,1,6
4,010300000020010001002010000003000000
See Also
FlowPolynomial
IsCutSet
IsNetwork
WeightMatrix
Download Help Document