]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/graph/example/dfs-parenthesis.cpp
bump version to 18.2.2-pve1
[ceph.git] / ceph / src / boost / libs / graph / example / dfs-parenthesis.cpp
1 //=======================================================================
2 // Copyright 2001 Jeremy G. Siek, Andrew Lumsdaine, Lie-Quan Lee,
3 //
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 //=======================================================================
8
9 /*
10 IMPORTANT!!!
11 ~~~~~~~~~~~~
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.
14 */
15
16 #include <boost/graph/graphviz.hpp>
17 #include <boost/graph/depth_first_search.hpp>
18
19 char name[] = "abcdefghij";
20
21 struct parenthesis_visitor : public boost::default_dfs_visitor
22 {
23 template < class Vertex, class Graph >
24 void start_vertex(Vertex v, const Graph&)
25 {
26 std::cout << ' ';
27 }
28 template < class Vertex, class Graph >
29 void discover_vertex(Vertex v, const Graph&)
30 {
31 std::cout << "(" << name[v] << ' ';
32 }
33 template < class Vertex, class Graph >
34 void finish_vertex(Vertex v, const Graph&)
35 {
36 std::cout << ' ' << name[v] << ")";
37 }
38 };
39
40 int main()
41 {
42 using namespace boost;
43 GraphvizGraph g;
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)]
48 << ')' << std::endl;
49 parenthesis_visitor paren_vis;
50 depth_first_search(g, visitor(paren_vis));
51 std::cout << std::endl;
52 return 0;
53 }