1 //=======================================================================
2 // Copyright 2001 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 //=======================================================================
12 This example uses interfaces that have been deprecated and removed from
13 Boost.Grpah. Someone needs to update it, as it does NOT compile.
16 #include <boost/graph/graphviz.hpp>
17 #include <boost/graph/depth_first_search.hpp>
19 char name
[] = "abcdefghij";
21 struct parenthesis_visitor
: public boost::default_dfs_visitor
23 template < class Vertex
, class Graph
>
24 void start_vertex(Vertex v
, const Graph
&)
28 template < class Vertex
, class Graph
>
29 void discover_vertex(Vertex v
, const Graph
&)
31 std::cout
<< "(" << name
[v
] << ' ';
33 template < class Vertex
, class Graph
>
34 void finish_vertex(Vertex v
, const Graph
&)
36 std::cout
<< ' ' << name
[v
] << ")";
42 using namespace boost
;
44 read_graphviz("figs/dfs-example.dot", g
);
45 graph_traits
< GraphvizGraph
>::edge_iterator e
, e_end
;
46 for (boost::tie(e
, e_end
) = edges(g
); e
!= e_end
; ++e
)
47 std::cout
<< '(' << name
[source(*e
, g
)] << ' ' << name
[target(*e
, g
)]
49 parenthesis_visitor paren_vis
;
50 depth_first_search(g
, visitor(paren_vis
));
51 std::cout
<< std::endl
;