Boost logo

Boost Users :

Subject: Re: [Boost-users] Boost Graph: edge indices
From: Jeremiah Willcock (jewillco_at_[hidden])
Date: 2010-04-01 09:40:36

On Thu, 1 Apr 2010, Gábor Szuromi wrote:

> Hi!
> The edge_index internal property map is not created by default, so you
> have to define it explicitly:
> typedef adjacency_list<vecS, vecS, directedS, Foo*,
> property<edge_index_t, std::size_t> > MyGraph;
> typedef property_map<MyGraph, edge_index_t>::type MyEdgeIndexMap;
> ...
> // Retrieve the edge index map associated with the graph
> MyEdgeIndexMap emap = get(edge_index, g);
> ...
> // Convert the edge descriptor to an integer value
> cout << index[ get(emap, e, g) ] << endl;

Note that you need to fill in the edge indices; they are not created
automatically for the graph type you have.

> The vertex descriptor is an integer value so it works with operator[],
> but edge descriptor is an std::pair<>, so you have to convert it to an
> integer with the appropriate edge index map. This leaves only one
> question: how do you use bundled edge properties along with edge index
> map?

You don't need an edge index map for bundled edge properties. Your graph
doesn't currently have (from what is listed above) bundled edge
properties; if it did, you could do just g[e].whatever where "whatever" is
a member of your bundled edge property class.

-- Jeremiah Willcock

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at