Boost logo

Boost Users :

Subject: Re: [Boost-users] Adjacency List vertex access
From: Cosimo Calabrese (cosimo.calabrese_at_[hidden])
Date: 2011-05-04 13:34:03


Hi Carlo,

how you can read in:
http://www.boost.org/doc/libs/1_46_1/libs/graph/doc/adjacency_list.html

the "boost::vertex" free function returns a vertex_descriptor, not a
vertex_iterator.

Try with this:

graph_traits<Graph>::vertex_descriptor vd;
vd = vertex(i,g);

You should obtain a vertex_descriptor of the requested vertex. If you
need a vertex_iterator, you can try with this:

graph_traits<Graph>::vertex_iterator it, end;
for (boost::tie( it, end ) = vertices(g); it != end; ++it)
   if ( i == *it )
     break;

Now "it" points to the requested vertex. I don't know a smart method to
retrieve it.

Hope this helps.

Best regards,
Cosimo Calabrese.

Il 04/05/2011 13.07, Carlo jardinier ha scritto:
> I try to use the adjacency list from boost. I can fill the list with
> vertices and edges, but somehow I cannot access a specific vertex or
> edge.
>
> For example this is not working (see test.cpp):
> **
> struct EdgeProperties {
> bool bConnectedBond;
> EdgeProperties(){bConnectedBond=false;}
> };
> struct VertexProperties{
> int index;
> int spin;
> bool bOnCluster;
> VertexProperties(): spin(){ bOnCluster = false;}
> ~VertexProperties(){ }
> };
> typedef adjacency_list< vecS, vecS, bidirectionalS, VertexProperties,
> EdgeProperties> Graph;
> typedef graph_traits< Graph>::vertex_iterator Vit;
>
> Graph g(9);
> unsigned int i = 3;
> Vit vi;
> vi = vertex(i,g);
> **
>
> I want vi to bi an iterator that points on the 3. vertex of the graph g.
> I attached the error message from g++ when compiling.
>
> Can anyone help?
>
>
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users


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