0% found this document useful (0 votes)
53 views6 pages

Modul Maximum Flow

The document discusses algorithms for finding maximum flow in a network: - Ford-Fulkerson algorithm finds augmenting paths in a residual graph to incrementally increase the flow. It has complexity O(|E|*f*) where f* is maximum flow. - Edmonds-Karp improves this to O(|V||E|^2) by using breadth-first search to find shortest-path augmenting paths at each iteration. - Dinic's algorithm also uses layered graphs from BFS to send multiple flows, achieving complexity O(V^2E).

Uploaded by

Nasywa Syifa
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
0% found this document useful (0 votes)
53 views6 pages

Modul Maximum Flow

The document discusses algorithms for finding maximum flow in a network: - Ford-Fulkerson algorithm finds augmenting paths in a residual graph to incrementally increase the flow. It has complexity O(|E|*f*) where f* is maximum flow. - Edmonds-Karp improves this to O(|V||E|^2) by using breadth-first search to find shortest-path augmenting paths at each iteration. - Dinic's algorithm also uses layered graphs from BFS to send multiple flows, achieving complexity O(V^2E).

Uploaded by

Nasywa Syifa
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 6

Residual Network

Augmenting Path

Ford Fulkerson Algorithm


Ford-Fulkerson has a complexity of O(∣E∣⋅f∗), where f∗ is the maximum flow of the network.

Ford-Fulkerson Algorithm Graph G, source s, sink t


initialize flow to 0
1 path = findAugmentingPath(G, s, t)
2 while path exists:
3 augment flow along path
4 G_f = createResidualGraph()
5 path = findAugmentingPath(G_f, s, t)
6 return flow
7

Here is a version of the pseudo-code that explains the flow augmentation more in depth:

flow = 0
1 for each edge (u, v) in G:
2
flow(u, v) = 0
3 while there is a path, p, from s -> t in residual network G_f:
4 residual_capacity(p) = min(residual_capacity(u, v) : for (u, v) in p)
5 flow = flow + residual_capacity(p)
6 for each edge (u, v) in p:
7 if (u, v) is a forward edge:
8 flow(u, v) = flow(u, v) + residual_capacity(p)
9 else:
10 flow(u, v) = flow(u, v) - residual_capacity(p)
11 return flow
12

An edge in the residual graph is a 'forward edge' if the edge existed in the original graph G. If it is a
reversal of an original edge, it is called a 'backwards edge.'

Edmonds-Karp Algorithm

Edmonds-Karp improves the runtime of Ford-Fulkerson, which is O(∣E∣⋅f∗) to O(∣V∣⋅∣E∣2). BFS finds the
path with least number of vertices visited from source to sink.

1 inputs
2 C[n x n] : Capacity Matrix
3 E[n x n] : Adjacency Matrix
4 s : source
5 t : sink
6 output
7 f : maximum flow
8 Edmonds-Karp:
9 f = 0 // Flow is initially 0
10 F = [n x n] // residual capacity array
11 while true:
12 m, P = Breadth-First-Search(C, E, s, t, F)
13 if m = 0:
14 break
15 f = f + m
16 v = t
while v != s:
17 u = P[v]
18 F[u, v] = F[u, v] - m
19 F[v, u] = F[v, u] + m
20 v = u
21 return f
22

Max-flow min-cut theorem


This theorem states that the maximum flow through any network from a given source to a given sink
is exactly the sum of the edge weights that, if removed, would totally disconnect the source from the
sink. In other words, for any network graph and a selected source and sink node, the max-flow from
source to sink = the min-cut necessary to separate source from sink

Dinic Algorithm
1) Initialize residual graph G as given graph.
1) Do BFS of G to construct a level graph (or assign levels to vertices) and also check if more flow is
possible.
a) If more flow is not possible, then return.
b) Send multiple flows in G using level graph until blocking flow is reached. Here using level graph
means, in every flow, levels of path nodes should be 0, 1, 2... (in order) from s to t.

A flow is Blocking Flow if no more flow can be sent using level graph, i.e., no more s-t path exists
such that path vertices have current levels 0, 1, 2… in order.

Time complexity is O(V2E)

You might also like