[BGL] Change order of edge iterator
I want to be able to iterate through the edges in any given order, not just the order specified by tie(edge_iter, edges_end) = edges(g);. Is it possible to do something like the following. typename graph_traits<Graph>::edge_iterator edge_iter1, edges_end1, edge_iter2, edges_end2, edge_iter3, edges_end3; tie(edge_iter1, edges_end1) = edges(g); sort(edge_iter1, edges_end1, ordering_1()); tie(edge_iter2, edges_end2) = edges(g); sort(edge_iter2, edges_end2, ordering_2()); tie(edge_iter3, edges_end3) = edges(g); sort(edge_iter3, edges_end3, ordering_3()); (ordering_x() specified by some struct) Then I would have 3 different orderings of the edges available. Would this work or should I use an iterator adapter, or create a map and (if its possible) obtain an iterator from the mapping, or something else. Thanks
tie(edge_iter1, edges_end1) = edges(g); sort(edge_iter1, edges_end1, ordering_1());
tie(edge_iter2, edges_end2) = edges(g); sort(edge_iter2, edges_end2, ordering_2());
tie(edge_iter3, edges_end3) = edges(g); sort(edge_iter3, edges_end3, ordering_3());
(ordering_x() specified by some struct)
Then I would have 3 different orderings of the edges available.
Would this work or should I use an iterator adapter, or create a map and (if its possible) obtain an iterator from the mapping, or something else.
I think your best bet may be simply sorting a vector of iterators:
pair
participants (2)
-
Andrew Sutton
-
John Robertson