Difference between revisions of "Boost/BGL/Directed/IterateEdges"
From ProgrammingExamples
Daviddoria (Talk | contribs) (Created page with '==IterateEdges.cpp== <source lang="cpp"> #include <iostream> #include <boost/graph/adjacency_list.hpp> typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::undirected…') |
Daviddoria (Talk | contribs) |
(No difference)
|
Revision as of 18:59, 15 November 2011
IterateEdges.cpp
#include <iostream> #include <boost/graph/adjacency_list.hpp> typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS> Graph; int main(int,char*[]) { // Create a graph object Graph g; Graph::vertex_descriptor v0 = boost::add_vertex(g); Graph::vertex_descriptor v1 = boost::add_vertex(g); std::pair<Graph::edge_descriptor, bool> e0 = boost::add_edge(v0, v1, g); std::pair<Graph::edge_iterator, Graph::edge_iterator> edgeIteratorRange = boost::edges(g); for(Graph::edge_iterator edgeIterator = edgeIteratorRange.first; edgeIterator != edgeIteratorRange.second; ++edgeIterator) { std::cout << *edgeIterator << std::endl; } return 0; }
CMakeLists.txt
cmake_minimum_required(VERSION 2.6) Project(IterateEdges) set(Boost_USE_MULTITHREADED ON) FIND_PACKAGE(Boost 1.38 COMPONENTS required) INCLUDE_DIRECTORIES(${INCLUDE_DIRECTORIES} ${Boost_INCLUDE_DIRS}) LINK_DIRECTORIES(${LINK_DIRECTORIES} ${Boost_LIBRARY_DIRS}) ADD_EXECUTABLE(IterateEdges IterateEdges.cpp)