1 | #include <boost/graph/depth_first_search.hpp>
|
---|
2 | #include <boost/graph/adjacency_list.hpp>
|
---|
3 |
|
---|
4 | using namespace boost;
|
---|
5 |
|
---|
6 | struct VIZ : public default_dfs_visitor
|
---|
7 | {
|
---|
8 | template <class V, class G>
|
---|
9 | void finish_vertex(V v, const G&)
|
---|
10 | {
|
---|
11 | std::cout << "Finish vertex: " << v << std::endl;
|
---|
12 | }
|
---|
13 |
|
---|
14 | template <class E, class G>
|
---|
15 | void finish_edge(E e, const G&)
|
---|
16 | {
|
---|
17 | std::cout << "Finish edge: " << e << std::endl;
|
---|
18 | }
|
---|
19 | };
|
---|
20 |
|
---|
21 | int main()
|
---|
22 | {
|
---|
23 | adjacency_list<vecS, vecS, directedS> g(4);
|
---|
24 | adjacency_list<vecS, vecS, directedS>::vertex_descriptor a,b,c,d;
|
---|
25 |
|
---|
26 | a = vertex(0, g);
|
---|
27 | b = vertex(1, g);
|
---|
28 | c = vertex(2, g);
|
---|
29 | d = vertex(3, g);
|
---|
30 |
|
---|
31 | add_edge(a,b,g);
|
---|
32 | add_edge(a,c,g);
|
---|
33 | add_edge(b,d,g);
|
---|
34 | add_edge(c,d,g);
|
---|
35 |
|
---|
36 | depth_first_search(g, visitor(VIZ ()));
|
---|
37 | }
|
---|