]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/msm/example/mpl_graph/adjacency_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)
5 // mplgraph.cpp : Defines the entry point for the console application.
8 #include <boost/msm/mpl_graph/adjacency_list_graph.hpp>
9 #include <boost/msm/mpl_graph/mpl_utils.hpp>
10 #include <boost/mpl/equal.hpp>
13 namespace mpl_graph
= boost::msm::mpl_graph
;
14 namespace mpl_utils
= mpl_graph::mpl_utils
;
15 namespace mpl
= boost::mpl
;
18 test graph and tests are almost identical to incidence_list_graph.cpp
27 struct A
{}; struct B
{}; struct C
{}; struct D
{}; struct E
{}; struct F
{}; struct G
{};
30 struct A_B
{}; struct B_C
{}; struct C_D
{}; struct C_E
{}; struct C_F
{}; struct B_F
{};
33 mpl::pair
<A
, mpl::vector
<mpl::pair
<A_B
, B
> > >,
34 mpl::pair
<B
, mpl::vector
<mpl::pair
<B_C
, C
>,
35 mpl::pair
<B_F
, F
> > >,
36 mpl::pair
<C
, mpl::vector
<mpl::pair
<C_D
, D
>,
38 mpl::pair
<C_F
, F
> > >,
39 mpl::pair
<G
, mpl::vector
<> > >
41 typedef mpl_graph::adjacency_list_graph
<some_adjacency_list
> some_graph
;
43 BOOST_MPL_ASSERT(( boost::is_same
<mpl_graph::source
<B_C
,some_graph
>::type
, B
> ));
44 BOOST_MPL_ASSERT(( boost::is_same
<mpl_graph::source
<C_D
,some_graph
>::type
, C
> ));
46 BOOST_MPL_ASSERT(( boost::is_same
<mpl_graph::target
<C_D
,some_graph
>::type
, D
> ));
47 BOOST_MPL_ASSERT(( boost::is_same
<mpl_graph::target
<B_F
,some_graph
>::type
, F
> ));
50 // shouldn't assume the order but this seems to work
51 BOOST_MPL_ASSERT(( mpl_utils::set_equal
<mpl_graph::out_edges
<C
,some_graph
>::type
, mpl::vector
<C_D
,C_E
,C_F
> > ));
52 BOOST_MPL_ASSERT(( mpl_utils::set_equal
<mpl_graph::out_edges
<B
,some_graph
>::type
, mpl::vector
<B_C
,B_F
> > ));
54 BOOST_MPL_ASSERT_RELATION( (mpl_graph::out_degree
<B
,some_graph
>::value
), ==, 2 );
55 BOOST_MPL_ASSERT_RELATION( (mpl_graph::out_degree
<C
,some_graph
>::value
), ==, 3 );
58 BOOST_MPL_ASSERT(( mpl_utils::set_equal
<mpl_graph::in_edges
<C
,some_graph
>::type
, mpl::vector
<B_C
> > ));
59 BOOST_MPL_ASSERT(( mpl_utils::set_equal
<mpl_graph::in_edges
<F
,some_graph
>::type
, mpl::vector
<B_F
,C_F
> > ));
61 BOOST_MPL_ASSERT_RELATION( (mpl_graph::in_degree
<A
,some_graph
>::value
), ==, 0 );
62 BOOST_MPL_ASSERT_RELATION( (mpl_graph::in_degree
<F
,some_graph
>::value
), ==, 2 );
65 BOOST_MPL_ASSERT_RELATION( (mpl_graph::degree
<A
,some_graph
>::value
), ==, 1 );
66 BOOST_MPL_ASSERT_RELATION( (mpl_graph::degree
<C
,some_graph
>::value
), ==, 4 );
68 BOOST_MPL_ASSERT(( mpl_utils::set_equal
<mpl_graph::adjacent_vertices
<A
,some_graph
>::type
, mpl::vector
<B
> > ));
69 BOOST_MPL_ASSERT(( mpl_utils::set_equal
<mpl_graph::adjacent_vertices
<C
,some_graph
>::type
, mpl::vector
<D
,E
,F
> > ));
71 BOOST_MPL_ASSERT(( mpl_utils::set_equal
<mpl_graph::vertices
<some_graph
>::type
, mpl::vector
<A
,B
,C
,D
,E
,F
,G
> > ));
73 BOOST_MPL_ASSERT_RELATION( mpl_graph::num_vertices
<some_graph
>::value
, ==, 7 );
75 BOOST_MPL_ASSERT_RELATION( mpl_graph::num_edges
<some_graph
>::value
, ==, 6 );
78 int main(int argc
, char* argv
[])