
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 ? Best regards, Fabien Castan

On Wed, 8 Sep 2010, fabien.castan@free.fr 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

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. yes, you are right. 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. Yes, but in these 2 solutions I need to create a new graph. In my case, I need to sort the out_edges depending on values inside each node computed in a previous visit. But maybe the best solution is to create a new graph... There is no way to do a sort in place ?

On Thu, 9 Sep 2010, fab wrote:
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. yes, you are right.
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.
Yes, but in these 2 solutions I need to create a new graph. In my case, I need to sort the out_edges depending on values inside each node computed in a previous visit. But maybe the best solution is to create a new graph... There is no way to do a sort in place ?
Not using the "official" interfaces, AFAIK. What are you trying to do? Maybe there's a different algorithm in BGL that might do what you want. -- Jeremiah Willcock
participants (3)
-
fab
-
fabien.castan@free.fr
-
Jeremiah Willcock