Boost logo

Boost Users :

Subject: Re: [Boost-users] [Graph] newbie to graph (Andrew Sutton)
From: Phillip Jones (pjones13_at_[hidden])
Date: 2008-11-02 11:36:31


> The compilation output of the code above includes errors and can be found
> here:
>
> http://www.cs.huji.ac.il/~lweizm45/compile_output2.txt>

I'm only slightly less of a newbie when it comes to the boost graph
libraries. I ran into these same types of errors when I was trying to
use kruskal's minimum spanning tree algorithm. This error from your
output:

error: cannot convert `boost::detail::error_property_not_found' to
`long int' in assignment

indicates that there is a property that is not defined in your graph,
but that is needed by the kolmogorov_max_flow() function. There's two
options:

1) Use the internal properties, kolmogorov_max_flow() will use them.
2) Use bundled properties, you must explicitly tell
komogorov_max_flow() which property is which using bgl_named_params.

You've probably already noticed that the code listing here does not
work (as it appears your example is based from it):
http://www.boost.org/doc/libs/1_36_0/libs/graph/doc/kolmogorov_max_flow.html

For one thing, there's a typo in the #include line, but also it is
incomplete and leads to all the errors you listed. The code listed
here actually works:
http://www.boost.org/doc/libs/1_36_0/libs/graph/example/kolmogorov-eg.cpp

So you might prefer to use that as a base. Of course, it uses internal
properties, and the documentation indicates that bundled properties
are the preferred method now. For bundled properties, you would do
something like this:

struct Node {
    std::string name;
    long index;
    boost::default_color_type color;
    long distance;
    graph_traits<Graph>::edge_descriptor predecessor;
};

struct Arc {
    long capacity;
    long residual;
    graph_traits<Graph>::edge_descriptor rev;
};

and then call the function like so:

flow = kolmogorov_max_flow(g, s, t,
                    capacity_map(get(&Arc::capacity, g)).
                    residual_capacity_map(get(&Arc::residual, g)).
                    reverse_edge_map(get(&Arc::rev, g)).
                    predecessor_map(get(&Node::predecessor, g)).
                    color_map(get(&Node::color, g)).
                    distance_map(get(&Node::distance, g)).
                    vertex_index_map(get(&Node::index, g))
                    );

Note that each named parameter is separated by a period, not a comma.
I am not able to get an error free compile using bundled properties -
but by making the above changes it gets you down to about 2 errors.
Maybe you can figure out the last steps (I can't).

I stuck with using the internal properties because I had an example
that worked, and the documentation on how to get bundled properties
working with the functions is lacking.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net