AlgoFrames

Augment by hand

Warm-up · Trace the algorithm · about 6 min

Follow Edmonds-Karp from s to t. Each time BFS finds a path, type how many units it pushes. Edge labels show the room left.

Example 1

Input:

{"edges":[["s","a",4],["s","b",2],["a","b",3],["a","t",1],["b","t",5]],"source":"s","sink":"t"}

Output:

6

Three paths push 1, 2 and 3 units.

Constraints

  • BFS tries a node's edges in the order they are listed.
  • Each push sends the smallest room on the path.

Learn the idea first: Maximum flow: Ford-Fulkerson and Edmonds-Karp, a visual lesson.

More Maximum flow: Ford-Fulkerson and Edmonds-Karp problems