|
Boost Users : |
From: yg-boost-users_at_[hidden]
Date: 2002-09-15 19:04:23
Hello,
Q: one can construct a graph using adjacency_list<> and then immediately
iterate over the vertices, right?
The program below writes out the numbers 0 to 9 when compiled using
gcc 3.2 on linux. Ditto on my IRIX system, *unless* I try to
optimize. I expect this is a GCC optimizer bug, but I just want to be
sure I haven't overlooked something in the boost docs.
Thanks,
-S
#include <iostream>
#include <boost/graph/graph_traits.hpp>
#include <boost/graph/adjacency_list.hpp>
typedef boost::adjacency_list< boost::vecS, boost::vecS,
boost::undirectedS,
boost::no_property,
boost::property<boost::edge_weight_t,float>
> Graph;
typedef boost::graph_traits<Graph>::vertex_descriptor vertex_descriptor;
typedef boost::graph_traits<Graph>::edge_descriptor edge_descriptor;
int main()
{
Graph g( 10 );
boost::graph_traits<Graph>::vertex_iterator ui, ui_end;
for (boost::tie(ui, ui_end) = boost::vertices(g); ui != ui_end; ++ui) {
std::cout << "*ui = " << *ui << std::endl;
}
return 0;
}
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