Search code examples
algorithmford-fulkerson

Ford Fulkerson.. what is the purpose of the backwards edge?


I'm learning about the Ford Fulkerson algorithm and I'm confused by the purpose of the backwards edges, and how they help us reach a maximum flow. I've watched a couple different videos and read some documentation on the algorithm but nothing is clicking. Perhaps someone here can put it in a way that will make sense to me!


Solution

  • Gassa's comment is correct. Here is a simple example.

    Suppose you have a source S, a sink T, and two intermediate nodes A and B, and paths from S to A and A to T, and from S to B and B to T of capacity 1.

      A
     / \
    S   T
     \ /
      B
    

    Obviously there is a flow of weight 2 using each edge. Now, add an edge from A to B of capacity 1.

      A
     /|\
    S V T
     \|/
      B
    

    This doesn't increase the maximum flow, but it gives you a chance to mess up when you create a flow incrementally. You could start with S->A->B->T.

      A
     /|
    S V T
      |/
      B
    

    In order to find the maximum flow, you need to be able to decrease the flow from A to B. You can do this by increasing the flow along S->B->A->T.

      A         A         A
     /|         |\       / \
    S V T  +  S ^ T  =  S   T
      |/       \|        \ /
      B         B         B
    

    Going backwards along A->B means you decrease the flow from A to B.