[graph] edmund_karp_max_flow vs kolmogorov_max_flow color map
Hi! It seems there is an inconsistency (to me) between color tagging of vertices in edmund_karp_max_flow and kolmogorov_max_flow algorithms. In the documentation of kolmogorov_max_flow, it says: "If the color of a vertex after running the algorithm is white the vertex belongs to the source tree else it belongs to the sink-tree (used for minimum cuts)." In short, vertices linked to the source are white. However, for edmund_karp_max_flow, it says: "At the end of the algorithm, the white vertices define the minimum cut set." Thus in this case, it's the vertices connected to the sink that are white. Why the difference in color tagging between the two algorithms? -- François Duranleau LIGUM, Université de Montréal
Hi François,
On 3/6/07, François Duranleau
Hi!
It seems there is an inconsistency (to me) between color tagging of vertices in edmund_karp_max_flow and kolmogorov_max_flow algorithms.
In the documentation of kolmogorov_max_flow, it says:
"If the color of a vertex after running the algorithm is white the vertex belongs to the source tree else it belongs to the sink-tree (used for minimum cuts)."
In short, vertices linked to the source are white.
Yes, that's right. However, for
edmund_karp_max_flow, it says:
"At the end of the algorithm, the white vertices define the minimum cut set."
Thus in this case, it's the vertices connected to the sink that are white.
Why? Maybe the docs are not really accurate here. But I think this could
also mean, that this are the vertices connected to the source.
Why the difference in color tagging between the two algorithms?
For the reasons above, I think there are no differences.
Below is a short example which uses kolmogorov_mf and edmunds_karp_mf. It
can be run with the *.dat files from $(BOOST_ROOT)/libs/graph/examples like
this: edmunds_karp_maxflow < max_flow.dat
Cheers,
Stephan
#include <iostream>
#include <string>
#include ::type>::value_type tColorValue;
typedef boost::color_traits<tColorValue> tColorTraits;
for (tie(u_iter, u_end) = vertices(g); u_iter != u_end; ++u_iter)
if(col[*u_iter] == tColorTraits::white())
std::cout << "White:" << *u_iter < graph_traits < Graph >::vertex_iterator u_iter, u_end;
typedef boost::color_traitsboost::default_color_type tColorTraits;
for (tie(u_iter, u_end) = vertices(g); u_iter != u_end; ++u_iter)
if(col[*u_iter] == tColorTraits::white())
std::cout << "White:" << *u_iter <
On Wed, 7 Mar 2007, Stephan Diederich wrote:
On 3/6/07, François Duranleau
wrote: It seems there is an inconsistency (to me) between color tagging of vertices in edmund_karp_max_flow and kolmogorov_max_flow algorithms.
In the documentation of kolmogorov_max_flow, it says:
"If the color of a vertex after running the algorithm is white the vertex belongs to the source tree else it belongs to the sink-tree (used for minimum cuts)."
In short, vertices linked to the source are white.
However, for edmund_karp_max_flow, it says:
"At the end of the algorithm, the white vertices define the minimum cut set."
Thus in this case, it's the vertices connected to the sink that are white.
Why? Maybe the docs are not really accurate here. But I think this could also mean, that this are the vertices connected to the source.
Why the difference in color tagging between the two algorithms?
For the reasons above, I think there are no differences. Below is a short example which uses kolmogorov_mf and edmunds_karp_mf. It can be run with the *.dat files from $(BOOST_ROOT)/libs/graph/examples like this: edmunds_karp_maxflow < max_flow.dat
[snip example]
Mm, I am confused. I compiled and run your example, and yes, the results
are identical... But with the following example, I get inversed colors,
and the flow returned by edmund_karp_max_flow is 0. What am I doing wrong?
I use gcc-4.0.3 and Boost head cvs. I also tried with 1.33.1+kolmogorov,
same thing.
#include
Hi,
On 3/7/07, François Duranleau
On Wed, 7 Mar 2007, Stephan Diederich wrote:
On 3/6/07, François Duranleau
wrote: It seems there is an inconsistency (to me) between color tagging of vertices in edmund_karp_max_flow and kolmogorov_max_flow algorithms.
[snip] Hm, I am confused. I compiled and run your example, and yes, the results
are identical... But with the following example, I get inversed colors, and the flow returned by edmund_karp_max_flow is 0. What am I doing wrong? I use gcc-4.0.3 and Boost head cvs. I also tried with 1.33.1+kolmogorov, same thing.
First, thanks for the example. I could reproduce this here. But I don't have the time to look into this deeper before the weekend. One thing I've seen is that edmunds_karp requires the reverse-edge weights to be zero. But changing it didn't make it better. Changing the edge_weights from max() to something smaller made edmunds_karp at least return the same flow as kolmogorov_mf does. I'll look into it at the weekend. Cheers, Stephan
Hi François,
On 3/9/07, Stephan Diederich
Hi,
On 3/7/07, François Duranleau
wrote: On Wed, 7 Mar 2007, Stephan Diederich wrote:
On 3/6/07, François Duranleau
wrote: It seems there is an inconsistency (to me) between color tagging of vertices in edmund_karp_max_flow and kolmogorov_max_flow algorithms.
[snip]
Hm, I am confused. I compiled and run your example, and yes, the results
are identical... But with the following example, I get inversed colors, and the flow returned by edmund_karp_max_flow is 0. What am I doing wrong? I use gcc-4.0.3 and Boost head cvs. I also tried with 1.33.1+kolmogorov, same thing.
You're absolutely right. kolmogorov_max_flow uses exactly the inversed colors - which is bad. My previous example had a bug. I found it after reading your comment about the color_map. edmunds_karp creates one of its own if it doesn't find it in the named properties. I'll change the colors of kolmogorov_max_flow and report it to the list, once it's done. Thanks for pointing out this inconsistency! Cheers, Stephan
Hi,
On 3/10/07, Stephan Diederich
On 3/9/07, Stephan Diederich < stephan.diederich@googlemail.com> wrote:
On 3/7/07, François Duranleau
wrote: On Wed, 7 Mar 2007, Stephan Diederich wrote:
On 3/6/07, François Duranleau
wrote: It seems there is an inconsistency (to me) between color tagging of
vertices in edmund_karp_max_flow and kolmogorov_max_flow algorithms.
[snip]
Hm, I am confused. I compiled and run your example, and yes, the results
are identical... But with the following example, I get inversed colors, and the flow returned by edmund_karp_max_flow is 0. What am I doing wrong? I use gcc-4.0.3 and Boost head cvs. I also tried with 1.33.1+kolmogorov, same thing.
You're absolutely right. kolmogorov_max_flow uses exactly the inversed colors - which is bad. My previous example had a bug. I found it after reading your comment about the color_map. edmunds_karp creates one of its own if it doesn't find it in the named properties. I'll change the colors of kolmogorov_max_flow and report it to the list, once it's done.
This is fixed in current CVS. (kolmogorov_max_flow coloring was changed) Thanks again for pointing this out! Cheers, Stephan
participants (2)
-
François Duranleau
-
Stephan Diederich