Boost logo

Boost :

Subject: Re: [boost] [graph] out_edges sort
From: Jeremiah Willcock (jewillco_at_[hidden])
Date: 2010-09-08 14:31:08


On Wed, 8 Sep 2010, fabien.castan_at_[hidden] wrote:

> Hi,
> I would like to visit my graph in a particular order using a dfs visitor.
> To do this I tried to order the out_edges of each node.
>
> I use the std sort function, like this:
> GraphContainer::out_edge_iterator oe_it, oe_itEnd;
> boost::tie( oe_it, oe_itEnd ) = boost::out_edges( vd, graph );
> std::sort( oe_it, oe_itEnd, OrderEdge<GraphContainer>(graph) );
>
> But it does nothing. It seems that there is an empty operator= on out_edge_descriptor.
> So, how can I sort the out_edges ?

It's not so much that there's an empty operator=(), most likely; I believe
all or almost all of the graph types produce a new object whenever you
dereference an edge iterator, and so modifying it does not change the
graph. The graphs typically don't store edges in the same form that users
see them as, so the edge iterators don't give references into the internal
graph data. What kind of graph are you using? Can you just sort the
edges before you put them into the graph? Also, using something like setS
as the out edge container would probably give a sorted out edge order.

-- Jeremiah Willcock


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk