]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/msm/example/mpl_graph/incidence_list_graph.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / msm / example / mpl_graph / incidence_list_graph.cpp
1 // Copyright 2008-2010 Gordon Woodhull
2 // Distributed under the Boost Software License, Version 1.0.
3 // (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
4
5 // mplgraph.cpp : Defines the entry point for the console application.
6 //
7
8 #include <boost/msm/mpl_graph/incidence_list_graph.hpp>
9 #include <boost/msm/mpl_graph/mpl_utils.hpp>
10
11 namespace mpl_graph = boost::msm::mpl_graph;
12 namespace mpl_utils = mpl_graph::mpl_utils;
13 namespace mpl = boost::mpl;
14 /*
15 test graph:
16 A -> B -> C -\--> D
17 \ |--> E
18 \ \--> F
19 \-----/
20 */
21
22 // vertices
23 struct A{}; struct B{}; struct C{}; struct D{}; struct E{}; struct F{};
24
25 // edges
26 struct A_B{}; struct B_C{}; struct C_D{}; struct C_E{}; struct C_F{}; struct B_F{};
27
28 typedef mpl::vector<mpl::vector<A_B,A,B>,
29 mpl::vector<B_C,B,C>,
30 mpl::vector<C_D,C,D>,
31 mpl::vector<C_E,C,E>,
32 mpl::vector<C_F,C,F>,
33 mpl::vector<B_F,B,F> >
34 some_incidence_list;
35 typedef mpl_graph::incidence_list_graph<some_incidence_list> some_graph;
36
37 BOOST_MPL_ASSERT(( boost::is_same<mpl_graph::source<B_C,some_graph>::type, B> ));
38 BOOST_MPL_ASSERT(( boost::is_same<mpl_graph::source<C_D,some_graph>::type, C> ));
39
40 BOOST_MPL_ASSERT(( boost::is_same<mpl_graph::target<C_D,some_graph>::type, D> ));
41 BOOST_MPL_ASSERT(( boost::is_same<mpl_graph::target<B_F,some_graph>::type, F> ));
42
43 BOOST_MPL_ASSERT(( mpl_utils::set_equal<mpl_graph::out_edges<C,some_graph>::type, mpl::vector<C_D,C_E,C_F> > ));
44 BOOST_MPL_ASSERT(( mpl_utils::set_equal<mpl_graph::out_edges<B,some_graph>::type, mpl::vector<B_F,B_C> > ));
45
46 BOOST_MPL_ASSERT_RELATION( (mpl_graph::out_degree<B,some_graph>::value), ==, 2 );
47 BOOST_MPL_ASSERT_RELATION( (mpl_graph::out_degree<C,some_graph>::value), ==, 3 );
48
49 BOOST_MPL_ASSERT(( mpl_utils::set_equal<mpl_graph::in_edges<C,some_graph>::type, mpl::vector<B_C> > ));
50 BOOST_MPL_ASSERT(( mpl_utils::set_equal<mpl_graph::in_edges<F,some_graph>::type, mpl::vector<C_F,B_F> > ));
51
52 BOOST_MPL_ASSERT_RELATION( (mpl_graph::in_degree<A,some_graph>::value), ==, 0 );
53 BOOST_MPL_ASSERT_RELATION( (mpl_graph::in_degree<F,some_graph>::value), ==, 2 );
54
55 BOOST_MPL_ASSERT_RELATION( (mpl_graph::degree<A,some_graph>::value), ==, 1 );
56 BOOST_MPL_ASSERT_RELATION( (mpl_graph::degree<C,some_graph>::value), ==, 4 );
57
58 BOOST_MPL_ASSERT(( mpl_utils::set_equal<mpl_graph::adjacent_vertices<A,some_graph>::type, mpl::vector<B> > ));
59 BOOST_MPL_ASSERT(( mpl_utils::set_equal<mpl_graph::adjacent_vertices<C,some_graph>::type, mpl::vector<D,E,F> > ));
60
61 BOOST_MPL_ASSERT(( mpl_utils::set_equal<mpl_graph::vertices<some_graph>::type, mpl::vector<A,B,C,D,E,F> > ));
62
63 BOOST_MPL_ASSERT_RELATION( mpl_graph::num_vertices<some_graph>::value, ==, 6 );
64
65 BOOST_MPL_ASSERT_RELATION( mpl_graph::num_edges<some_graph>::value, ==, 6 );
66
67
68 int main(int argc, char* argv[])
69 {
70 return 0;
71 }
72