Edmonds-Karp Algorithm

The Edmonds-Karp algorithm is the Ford-Fulkerson method but in which we select a shortest augmenting path (path with fewest no. of edges) each iteration.

Edmonds-Karp method

def edmonds_karp(G): # G = (V, E, l, u, s, t)
	f = zero flow # f(u, v) = 0 for each (u, v) in E
	
	while True:
		G_f = # (1) construct residual network
		p = # (2) find shortest augmenting path in G_f (use BFS)
		if p in None:
			# current flow is optimal
			return f
		
		f = f ^ f_p # (3) path augmentation

Running time of Edmonds-Karp

Each iteration takes time and there are iterations, so total running time is . This bound does not depend on values of edge capacities or maximum value of a flow.

The bound on number of iterations follows from the claim:

  • Let denote number of iterations in Edmonds-Karp, and let denote the lengths of augmenting paths selected in iterations . So we have:
    1. the same length appears in sequence at most times
  • This claim implies the number of iterations is . (we omit the proof)

Other maximum-flow algorithms

Definitely not examined.

Augmenting path algorithms:

  • modified Edmonds-Karp
  • Dinic’s
  • fastest known “blocking flow” algorithm

“Preflow-push” algorithms

  • generic algorithm
  • lift-to-front algorithm
  • if special data structure used:

Maximum bipartite matching problem

Construct a bipartite graph with nodes on one side and nodes on the other side. An edge means that task can be done by employee .

A matching in a bipartite graph is a subset of edges such that each node belongs to at most one edge in .

Solve using maximum flow problem

For a given bipartite graph , we construct the following flow network , with all edge capacities equal to : There is a one-to-one correspondence between matchings in and integral flows in . An edge in a given matching corresponds to a path flow of value from to which passes over the edge .

For a matching in and the corresponding integral flow in , the size of the matching is equal to the value of flow . Hence, finding a maximum-size matching in is equivalent to finding a maximum integral flow in

Running time is where and are nodes and edges in . At most iterations (since value of a maximum flow in is at most ) and each iteration takes time.

Example 'resource assignment' problem

Consider the problem where:

  • We have employees and tasks .
  • Each employee can do some of the tasks, depending on skills.
  • We want to allocate tasks such that:
    • Each employee gets at most one task
    • Each task is given to at most one employee
    • Each employee can only get a task which this employee can do
    • Largest possible number of tasks are allocated

We can model this as the maximum bipartite matching problem.

In our application, a matching is a feasible allocation (each employee gets at most one task, each task given to at most one employee, each employee can only get a task which the employee can do).

Hence, maximising the number of allocated tasks is equivalent to finding corresponding bipartite graph matching of the maximum size.

Minimum flow problem

In the minimum flow problem, we want to send the minimum amount of flow from the source to the sink, satisfying upper and lower bounds on edge flows.

The input is a flow network where:

  • is a set of nodes
  • is a set of directed edges
  • For each , are the lower and upper bounds on the flow of the given edge.
  • Two distinguished vertices: source and sink .
  • As before, assume if is an edge in , then is not an edge.

A feasible flow from to is a function on the edges, which satisfies the flow conservation constraints at all vertices other than and , and the lower and upper capacity bounds:

Algorithm

A minimum flow can be computed using 2 steps:

  1. Compute a feasible flow , that is, a flow which satisfies all lower and upper bounds on flows of edges.

  2. In residual network , compute maximum flow from to . (we want to send back from to any ‘excess’ flow)

    For an edge ,

    • Where
    • We have residual capacities:

    Visually:

    With this definition of residual capacities, the feasibility of the current flow will be maintained: flow on each edge will remain between the lower and upper bounds.

The final flow, interpreted in original network is a minimum flow.

Each of the two steps can be completed using a maximum flow algorithm.

For the following graph, interpret as lower and upper bounds, and as upper bound with lower bound .

For each edge with positive lower bound , we send units of flow along these edges, creating supply and demand at various vertices. We consider and to have unlimited supply and demand.

Find a feasible flow which satisfies the supplies and demands at all vertices other than and .

We add a new source (with edges to supply vertices) and a new sink (with edges from demand vertices) and use a maximum-flow algorithm to find a flow which saturates all added edges adjacent to vertices other than and .

If there is no flow which saturates all added edges adjacent to supply / demand vertices (other than and ) then there is no feasible flow in original network.

If a feasible flow has been found, then construct the residual network (of computed feasible flow) and compute a maximum flow in this network from to .

This computation returns back to as much flow as possible, while keeping the flow feasible. That way, when no more flow can be returned to , the final flow is a minimum feasible flow.

slides 18

Explanation of why algorithm works

  • In the residual network of the final flow , there is no augmenting path from to .
  • This means there is a cut with no residual edges from to .
  • For this cut :
    • For each edge from to , .
    • For each edge from to , (mistake in slides?).
  • Value of the flow is equal to the net flow across cut which is equal to:
  • Value of any feasible flow is at least right-hand side value above.
  • We conclude that the computed flow is a minimum feasible flow in the input network.

Example 'worker assignment' problem

0 items under this folder.