Boost logo

Boost Users :

Subject: Re: [Boost-users] BGL edge iteration questions
From: Jeremiah Willcock (jewillco_at_[hidden])
Date: 2011-06-07 09:49:58


On Mon, 6 Jun 2011, David Doria wrote:

> 1) When is it appropriate to use adjacency_list directly vs using
> directed_graph and undirected_graph?

I generally just use adjacency_list, since the parameters are easy to look
up.

> 2) I am trying to iterate over the edges of a directed_graph:
> http://codepad.org/jO3rJLtF
>
> In the first method I tried:
>
> typedef boost::graph_traits < Graph >::out_edge_iterator out_edge_iterator;
>  std::pair<out_edge_iterator, out_edge_iterator> outEdges =
>    boost::out_edges(v1, g);
>
> , memory addresses seem to be output instead of vertex ids.

Those are the vertex descriptors; they are void*'s for adjacency_list
graphs with listS vertex containers (of which directed_graph is one).

> In the second method:
>
>  typedef boost::property_map<Graph, boost::vertex_index_t>::type IndexMap;
>  IndexMap index = get(boost::vertex_index, g);
>
> , vertex ids are output, but I didn't specify if I wanted in edges or
> out edges?

The loop starting on line 50 of your code iterates through all of the
edges of the graph; the concepts of in edges and out edges relate to a
single vertex.

> When using adjacency_list directly, I used to have to
> specify boost::bidirectionalS:
>
> typedef boost::adjacency_list<boost::vecS, boost::vecS,
> boost::bidirectionalS> Graph;
>
> Is something like that required when using directed_graph?

The directed_graph class appears to use a bidirectionalS adjacency_list
automatically.

-- Jeremiah Willcock


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