Boost logo

Boost Users :

Subject: Re: [Boost-users] [BGL] How do I iterate over a labeled graph?
From: Jeremiah Willcock (jewillco_at_[hidden])
Date: 2012-10-12 12:41:08


On Fri, 12 Oct 2012, eric wrote:

> I am trying to iterate over my labeled_graph like so:
>
> struct Vertex
> {
> std::string vertType;
> };
> typedef Graph::vertex_iterator VertexIter;
> VertexIter vertexIter, vertexEnd;
> for (tie(vertexIter, vertexEnd) = vertices(graph); vertexIter != vertexEnd;
> vertexIter++)
> {
> std::string vertexType = graph[*vertexIter].vertType;
> }
>
> However, I get a compiler error saying that graph has no operator [] that
> accepts an unsigned int. How should I be doing what I'm trying to do?

The easiest is probably to use graph.graph()[*vertexIter]. That gets the
underlying graph then indexes that using the vertex.

-- 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