I was given a task to write an algorithm that finds the # of paths from s to t, formed by distinguished vertices.
exemple:
consider directed graph G=(V,E):

in the given exemple the answer is 2, one s,v,t or s,u,v,t and the other s,x,t
I saw the solution to this problem that goes by:
make a flow network Graph G’ as following:

where capacity of arcs of the form (i,i’) = 1 (i is some vertex) and
capacity of arcs of the form (i’,j) = infinity
they say running Edmonds Karp Algorithm on G’ would output the wanted flow.
now i dont seem to catch how does this solve the problem, i mean what if in the first iteration edmonds karp would accidently improve the flow with the path s,u,u’,v,v’,x,x’,t – in this case how would it get fixed?
thanks ahead.
How the network flow is equivalent with the original problem:
=> if there’s n paths, these will give a flow of n
<= if there’s a flow of size n, the edges with non-zero flow form n paths, every vertex is used at most once, because the capacity of i->i’ is 1 (and no edges leave i or end at i’)
don’t get distracted by the infinite capacity given to i->j edges, it may as well be 1 without changing anyting
For the description of the whole algorithm you should refer to some literature, like this one, but the path you’re writing won’t get selected first because of it’s length. The Edmonds-Karp algorithm starts with shortest paths possible.
Now, (ignoring this fact), you’re probably confused by the fact that such a path ‘blocks’ two other paths. If such a path (or combination of paths) is selected by previous iterations, there will still be an augmenting path that will use part of the previous path in backward direction (s-x-v’-t in your example).