1 //=======================================================================
2 // Copyright 2002 Jeremy G. Siek, Andrew Lumsdaine, Lie-Quan Lee,
4 // Distributed under the Boost Software License, Version 1.0. (See
5 // accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
7 //=======================================================================
10 #include <boost/graph/adjacency_list.hpp>
11 #include <boost/graph/undirected_dfs.hpp>
12 #include <boost/cstdlib.hpp>
16 Example graph from Tarjei Knapstad.
31 std::string name
[] = { "C0", "C1", "C2", "C3", "C4", "C5", "C6", "O7", "H8",
32 "H9", "H10", "H11", "H12", "H13", "H14", "H15" };
34 struct detect_loops
: public boost::dfs_visitor
<>
36 template < class Edge
, class Graph
> void back_edge(Edge e
, const Graph
& g
)
38 std::cout
<< name
[source(e
, g
)] << " -- " << name
[target(e
, g
)] << "\n";
42 int main(int, char*[])
44 using namespace boost
;
45 typedef adjacency_list
< vecS
, vecS
, undirectedS
, no_property
,
46 property
< edge_color_t
, default_color_type
> >
48 typedef graph_traits
< graph_t
>::vertex_descriptor vertex_t
;
50 const std::size_t N
= sizeof(name
) / sizeof(std::string
);
70 std::cout
<< "back edges:\n";
73 root_vertex(vertex_t(0))
75 .edge_color_map(get(edge_color
, g
)));
76 std::cout
<< std::endl
;
78 return boost::exit_success
;