Boost logo

Boost Users :

Subject: Re: [Boost-users] Boost Graph Library documentation unclear
From: Lindley M French (lfrench1_at_[hidden])
Date: 2009-04-26 09:04:27


Well, my code looks like

typedef boost::adjacency_list<
        boost::listS, boost::vecS, boost::undirectedS,
        RegionProperties, EdgeProperties> Graph;

template <typename Graph>
struct edge_off
{
        edge_off(): G(NULL) { }
        edge_off(const Graph &G) : m_G(&G) { }
        template <typename Edge>
        bool operator()(const Edge& e) const
        {
                return !(*G)[e].on;
        }
        const Graph *G;
};

....

Graph G;
....

filtered_graph<Graph, edge_off<Graph> > G_off_edges(G, edge_off<Graph>(G));
        
for (tie(ei, ei_end) = edges(G_off_edges); ei != ei_end; ++ei)
{
        size_t v1 = G_off_edges[source(*ei,G_off_edges)].vertex_index;
        size_t v2 = G_off_edges[target(*ei,G_off_edges)].vertex_index;
        ....
}

And I'm getting compiler errors that vertex_index is not a member of my class RegionProperties. I suppose this means that filtered_graph hides the vertex_index attribute of the underlying graph, even though I'm not filtering the vertexes at all? Can I use the returns of source and target as *if* they were indexes?

Also, do source and target refer to the two different ends of an undirected edge? That's another thing I wasn't sure about from the docs. Seemed reasonable, but I wish it were stated.

> I've been trying to use the Boost Graph Library. For the most part I'm
> working it out. However, I'm finding the documentation annoyingly
> decentralized....it isn't interlinked enough, at the very least. Too hard to
> go from "how do I use X" to "oh, here's the documentation on X." Took me
> half an hour just to find *something* on the add_edge function (turns out
> it's on the Concepts page?), and what's there *barely* qualifies as a
> prototype, much less a proper man page.

Concepts are similar "STL Concepts" (
http://www.sgi.com/tech/stl/table_of_contents.html). They classify and
describe the operations available to /all/ graph data structures (e.g.,
adjacency_list or matrix), which is why it might seem to barely qualify as a
prototype.

> My current question is regarding properties. Some of the algorithms specify
> the "edge_weight" property as if it's something all edges have, and the
> vertex_index property as if it's something all vecS-specified graphs have.
> Yet I can't find any documentation explicitly confirming this, and my
> compiler seems to disagree in any case.
>
> http://www.boost.org/doc/libs/1_38_0/libs/graph/doc/kruskal_min_spanning_tree.html

 No edges are weighted by default. The easiest way to weight a graph is to
used bundled properties (
http://www.boost.org/doc/libs/1_38_0/libs/graph/doc/bundles.html) and create
a property_map over a member pointer.

Currently, only adjacency_list<OEL, vecS, D, VP, EP, GP, EL> has a
vertex_index property by default. The OEL, D, etc. are just placeholders for
any template argument.

Can something be done about the state of the documentation, and is there a
> comprehensive list of default properties available somewhere (together with
> how those are replaced or supplemented when user properties are introduced)?

I'm currently rewriting the documentation, but that won't be ready until
1.40 at the earliest.

Andrew Sutton
andrew.n.sutton_at_[hidden]


_______________________________________________
Boost-users mailing list
Boost-users_at_[hidden]
http://lists.boost.org/mailman/listinfo.cgi/boost-users



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