Boost logo

Boost Users :

From: Douglas Gregor (doug.gregor_at_[hidden])
Date: 2007-03-05 21:27:55


On Mar 5, 2007, at 11:17 AM, Shufei Fan wrote:
> In my application, the order in which edges are retreaved is also
> important to
> me. So my question is, when I iterate through an vertex's
> out_edges, do they
> show up in the order in which the edges are inserted, or any other
> principals
> are used in order of iteration? Example:
> ......
> typename graph_traits<Graph>::out_edge_iterator out_i, out_end;
> typename graph_traits<Graph>::edge_descriptor e;
> for (tie(out_i, out_end) = out_edges(v, g);
> out_i != out_end; ++out_i)
> {
> e = *out_i;
> Vertex src = source(e, g), targ = target(e, g);
> std::cout << "(" << get(vertex_id, src)
> << "," << get(vertex_id, targ) << ") ";
> }
> ......
> How are these edges ordered in the output? And is it right all
> those iterators
> iterates in the same principals/order?

The document doesn't define this, but it should. It depends on
precisely which graph type you're using, but...

If you're using an adjacency list with OutEdgeListS=setS, or if
you're using an adjacency matrix, the out-edges will be ordered
increasing order of the target.
If you're using an adjacency list with any other OutEdgeListS, or if
you're using a compressed sparse row graph, the out-edges will have
the same order as the order that they were inserted into the graph.

        Cheers,
        Doug


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