Search code examples
ford-fulkerson

Continue the Ford-Fulkelson


I am trying to learn the Ford-Fulkerson method. I've made up an example for practicing and at some point I can't continue incrementing the flow but I know the flow could be higher.

enter image description here

First of all, I have incremented the path s -> 1 -> 2 -> t. And now I can't find any path for incrementing the flow. I know that if I took path a -> 1 -> 5 -> 6 -> t first, then I could increment path s -> 3 -> 4 -> 2 -> t but if I had to implement it I wouldn't know how to do it.

What am I doing wrong?


Solution

  • I figured it out. I didn't know that it was possible to use edges in the opposite direction to the arrow.

    enter image description here

    So we can traverse the path s -> 3 -> 4 -> 2 -> 1 -> 5 -> 6 -> t.

    enter image description here

    Then we get the expected result.