
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?

On Wednesday, 4. May 2011 13:07:31 Carlo jardinier wrote:
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.
Here (gcc-4.3.4 and boost-1.42), I get no error messages. It compiles fine. What is your system configuration please?
Can anyone help?
Best, Cedric

Hi Cedric, I'm using boost 1.4.6 from Debian testing. gcc is 4.3.5. Im compiling the file with "g++ test.cpp" or do you have to specify any library or include? -- View this message in context: http://boost.2283326.n4.nabble.com/Adjacency-List-vertex-access-tp3495589p34... Sent from the Boost - Users mailing list archive at Nabble.com.

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@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

Hi Cosimo, Hmm maybe this has changed from version 1.42 to 1.46? But I can't believe that there is no simpler way to get an iterator to a given vertex.... I will install 1.42 and try it out there. -- View this message in context: http://boost.2283326.n4.nabble.com/Adjacency-List-vertex-access-tp3495589p34... Sent from the Boost - Users mailing list archive at Nabble.com.

OK with version 1.42 (1.42.0-4 0 from Debian Wheezy) this works, but I get the Warning: g++ test.cpp In file included from /usr/include/c++/4.3/backward/hash_set:64, from /usr/include/boost/pending/container_traits.hpp:23, from /usr/include/boost/graph/detail/adjacency_list.hpp:31, from /usr/include/boost/graph/adjacency_list.hpp:324, from test.cpp:1: /usr/include/c++/4.3/backward/backward_warning.h:33:2: warning: #warning This file includes at least one deprecated or antiquated header which may be removed without further notice at a future date. Please use a non-deprecated interface with equivalent functionality instead. For a listing of replacement headers and interfaces, consult the file backward_warning.h. To disable this warning use -Wno-deprecated. -- View this message in context: http://boost.2283326.n4.nabble.com/Adjacency-List-vertex-access-tp3495589p34... Sent from the Boost - Users mailing list archive at Nabble.com.

Well, I'm working with Boost 1.46.1, Visual Studio 2010, and I detect an
error like yours.
I don't understand why you need an iterator that point to a vertex. If
you need it, I presume that you want to dereference it, obtaining the
correspondent vertex_descriptor. The particular implementation of
adjacency_list that you have choosed (vecS, vecS) implements a
vertex_descriptor that corresponds to the index of the vertex. If you
take a look at the definition of boost::vertex function you can see it:
template
OK with version 1.42 (1.42.0-4 0 from Debian Wheezy) this works, but I get the Warning:
g++ test.cpp In file included from /usr/include/c++/4.3/backward/hash_set:64, from /usr/include/boost/pending/container_traits.hpp:23, from /usr/include/boost/graph/detail/adjacency_list.hpp:31, from /usr/include/boost/graph/adjacency_list.hpp:324, from test.cpp:1: /usr/include/c++/4.3/backward/backward_warning.h:33:2: warning: #warning This file includes at least one deprecated or antiquated header which may be removed without further notice at a future date. Please use a non-deprecated interface with equivalent functionality instead. For a listing of replacement headers and interfaces, consult the file backward_warning.h. To disable this warning use -Wno-deprecated.
-- View this message in context: http://boost.2283326.n4.nabble.com/Adjacency-List-vertex-access-tp3495589p34... Sent from the Boost - Users mailing list archive at Nabble.com.

you are right, I think I can use the vertex_descriptor instead of the iterator. I'll try this out, because writing a code that works only for boost <1.42 makes not much sense... -- View this message in context: http://boost.2283326.n4.nabble.com/Adjacency-List-vertex-access-tp3495589p34... Sent from the Boost - Users mailing list archive at Nabble.com.
participants (4)
-
Carlo jardinier
-
Caro Jardinier
-
Cedric Laczny
-
Cosimo Calabrese