Search code examples
algorithmgraphgraph-theorybellman-fordnetwork-flow

Bellman-Ford or Network Flow for findin maximum number of distinct path?


We have a directed Graph (without weights), G(V, E), with two vertex s and t such that in-degree of s and out-degree of t are equals to 0. we want to find maximum number of distinct-edges paths from s to t. by using which algorithm we can do this. Bellman-Ford, Dijkestra, Huffman and Network Flow. I think Huffman so irrelevant, but how about others? I think Network Flow is the answer, but I have no idea why? stackeeeers, please help me!


Solution

  • You can do it with Network Flow. It even tells you how on wikipedia:

    Maximum edge-disjoint path

    Given a directed graph G = (V, E) and two vertices s and t, we are to find the maximum number of edge-disjoint paths from s to t. This problem can be transformed to a maximum flow problem by constructing a network N = (V, E) from G with s and t being the source and the sink of N respectively and assign each edge with unit capacity.

    The intuition behind this is that the maximum flow algorithms basically solve your problem while finding the augmenting paths. What an augmenting path is is best explained in this SO question I think, by Ivaylo Strandjev:

    An augmenting path is a simple path - a path that does not contain cycles - through the graph using only edges with positive capacity from the source to the sink. So the statement above is somehow obvious - if you can not find a path from the source to the sink that only uses positive capacity edges, then the flow can not be increased(by the way the proof of that statement is not that easy).