Question

i am using bfs to find augmenting path.but it is producing same path every time.but ford fulkerson algorithm requires that,we choose different path every time from source to sink,so can somebody suggest me how to modify bfs so that it produces different path every time between source and sink.graph is directed and weighted

Was it helpful?

Solution

You need to make sure that the BFS ignores edges where all of the capacity has been used. Usually, the BFS is being run on the so-called residual network, in which each edge capacity tells how much capacity remains on that edge (given the flow you've sent through that edge). You can either maintain a separate residual graph, or you can have an implicit one by making the BFS look at the difference between the original capacity and the current flow for each edge (and treating an edge as absent if its capacity is zero).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top