|
Boost Users : |
Subject: [Boost-users] Boost Graph: edge indices
From: Trevor Harmon (Trevor.W.Harmon_at_[hidden])
Date: 2010-03-31 21:19:12
Hi,
In the Boost Graph library, vertices have an index (vertex_index_t),
and I was under the impression that edges have one, too. At least,
there's a predefined type called edge_index_t. However, I can't figure
out how to access an edge's index. For example, consider a graph
defined like:
typedef adjacency_list<vecS, vecS, directedS, Foo*> MyGraph;
typedef graph_traits<MyGraph>::vertex_descriptor Vertex;
typedef graph_traits<MyGraph>::edge_descriptor Edge;
And let's say I've got a vertex descriptor called "u". I can iterate
over u's outgoing edges like this:
typedef graph_traits<MyGraph>::out_edge_iterator out_iter;
std::pair<out_iter, out_iter> outp;
for (outp = out_edges(u, g); outp.first != outp.second; ++outp.first) {
Edge e = *outp.first;
Vertex v = target(e, g);
cout << index[v] << std::endl; // Works fine
cout << index[e] << std::endl; // Compiler error
}
In this example, index[v] works as expected, but index[e] gives me a
compiler error: "no match for operator[] in index[e]".
Perhaps my graph typedef needs to be changed so that its edges have a
property map for edge_index_t, although I'm not sure how to do that.
(And anyway I wouldn't expect vertices to have indices by default but
edges not...)
Thanks for any help,
Trevor
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