Boost graph library c++/ Minimum Cost Maximum Flow Algorithms

Mar 3, 2016 at 7:08pm
Hi all,
I am working on Minimum Cost Maximum Flow Algorithms with boost graph library but I could not get correct result. When I tried to solve the provided example in boost graph library, the correct answer should be 24 while the result return from the C++ code is 29. Here is the simple graph provided as an example in boost graph library:

s = 0;
t = 5;

EdgeAdder ea(g, weight, capacity, rev, residual_capacity);

ea.addEdge(0, 1, 4 ,2);
ea.addEdge(0, 2, 2 ,2);

ea.addEdge(1, 3, 2 ,2);
ea.addEdge(1, 4, 1 ,1);
ea.addEdge(2, 3, 1 ,1);
ea.addEdge(2, 4, 1 ,1);

ea.addEdge(3, 5, 4 ,20);
a.addEdge(4, 5, 2 ,20);

What should I do to fix this? I can't figure out how is computes the result of "29" out of this simple graph while the answer on paper is 24.
Mar 4, 2016 at 2:50pm
Have you read the documentation of that library?
Maybe there is a setting like radians vs. degrees that is causing your answer to be off.
Good luck!
Mar 5, 2016 at 6:30am
Hi,
Honestly, I want to raise another question. Currently, I used successive_shortest_path_nonnegative_weights algorithm to find the minimum cost of maximum flow problem in a graph. I want to extend my result to the simple shortest path problem when I assume that all arcs have capacity of 1. In this case, how can set the successive_shortest_path_nonnegative_weights function to just do calculation based on only ONE unit of flow from source node to sink node.
I tried this code but it doesn't work since I don't know how to specify the the possible amount of flow in my graph.

s = 0;
t = 5;
EdgeAdder ea(g, weight, capacity, rev, residual_capacity);
ea.addEdge(0, 1, 4 ,2);
ea.addEdge(0, 2, 2 ,2);
ea.addEdge(1, 3, 2 ,2);
ea.addEdge(1, 4, 1 ,1);
ea.addEdge(2, 3, 1 ,1);
ea.addEdge(2, 4, 1 ,1);
ea.addEdge(3, 5, 4 ,20);
ea.addEdge(4, 5, 2 ,20);

boost::successive_shortest_path_nonnegative_weights(g, s, t);
int cost2 = find_flow_cost(g);

What should I do in this case now?
Last edited on Mar 5, 2016 at 4:30pm
Topic archived. No new replies allowed.