]>
git.proxmox.com Git - ceph.git/blob - 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)
5 // mplgraph.cpp : Defines the entry point for the console application.
8 #include <boost/msm/mpl_graph/incidence_list_graph.hpp>
9 #include <boost/msm/mpl_graph/mpl_utils.hpp>
11 namespace mpl_graph
= boost::msm::mpl_graph
;
12 namespace mpl_utils
= mpl_graph::mpl_utils
;
13 namespace mpl
= boost::mpl
;
23 struct A
{}; struct B
{}; struct C
{}; struct D
{}; struct E
{}; struct F
{};
26 struct A_B
{}; struct B_C
{}; struct C_D
{}; struct C_E
{}; struct C_F
{}; struct B_F
{};
28 typedef mpl::vector
<mpl::vector
<A_B
,A
,B
>,
33 mpl::vector
<B_F
,B
,F
> >
35 typedef mpl_graph::incidence_list_graph
<some_incidence_list
> some_graph
;
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
> ));
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
> ));
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
> > ));
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 );
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
> > ));
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 );
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 );
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
> > ));
61 BOOST_MPL_ASSERT(( mpl_utils::set_equal
<mpl_graph::vertices
<some_graph
>::type
, mpl::vector
<A
,B
,C
,D
,E
,F
> > ));
63 BOOST_MPL_ASSERT_RELATION( mpl_graph::num_vertices
<some_graph
>::value
, ==, 6 );
65 BOOST_MPL_ASSERT_RELATION( mpl_graph::num_edges
<some_graph
>::value
, ==, 6 );
68 int main(int argc
, char* argv
[])