]> git.proxmox.com Git - ceph.git/blame - 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
CommitLineData
7c673cae
FG
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
11namespace mpl_graph = boost::msm::mpl_graph;
12namespace mpl_utils = mpl_graph::mpl_utils;
13namespace mpl = boost::mpl;
14/*
15 test graph:
16 A -> B -> C -\--> D
17 \ |--> E
18 \ \--> F
19 \-----/
20*/
21
22// vertices
23struct A{}; struct B{}; struct C{}; struct D{}; struct E{}; struct F{};
24
25// edges
26struct A_B{}; struct B_C{}; struct C_D{}; struct C_E{}; struct C_F{}; struct B_F{};
27
28typedef 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;
35typedef mpl_graph::incidence_list_graph<some_incidence_list> some_graph;
36
37BOOST_MPL_ASSERT(( boost::is_same<mpl_graph::source<B_C,some_graph>::type, B> ));
38BOOST_MPL_ASSERT(( boost::is_same<mpl_graph::source<C_D,some_graph>::type, C> ));
39
40BOOST_MPL_ASSERT(( boost::is_same<mpl_graph::target<C_D,some_graph>::type, D> ));
41BOOST_MPL_ASSERT(( boost::is_same<mpl_graph::target<B_F,some_graph>::type, F> ));
42
43BOOST_MPL_ASSERT(( mpl_utils::set_equal<mpl_graph::out_edges<C,some_graph>::type, mpl::vector<C_D,C_E,C_F> > ));
44BOOST_MPL_ASSERT(( mpl_utils::set_equal<mpl_graph::out_edges<B,some_graph>::type, mpl::vector<B_F,B_C> > ));
45
46BOOST_MPL_ASSERT_RELATION( (mpl_graph::out_degree<B,some_graph>::value), ==, 2 );
47BOOST_MPL_ASSERT_RELATION( (mpl_graph::out_degree<C,some_graph>::value), ==, 3 );
48
49BOOST_MPL_ASSERT(( mpl_utils::set_equal<mpl_graph::in_edges<C,some_graph>::type, mpl::vector<B_C> > ));
50BOOST_MPL_ASSERT(( mpl_utils::set_equal<mpl_graph::in_edges<F,some_graph>::type, mpl::vector<C_F,B_F> > ));
51
52BOOST_MPL_ASSERT_RELATION( (mpl_graph::in_degree<A,some_graph>::value), ==, 0 );
53BOOST_MPL_ASSERT_RELATION( (mpl_graph::in_degree<F,some_graph>::value), ==, 2 );
54
55BOOST_MPL_ASSERT_RELATION( (mpl_graph::degree<A,some_graph>::value), ==, 1 );
56BOOST_MPL_ASSERT_RELATION( (mpl_graph::degree<C,some_graph>::value), ==, 4 );
57
58BOOST_MPL_ASSERT(( mpl_utils::set_equal<mpl_graph::adjacent_vertices<A,some_graph>::type, mpl::vector<B> > ));
59BOOST_MPL_ASSERT(( mpl_utils::set_equal<mpl_graph::adjacent_vertices<C,some_graph>::type, mpl::vector<D,E,F> > ));
60
61BOOST_MPL_ASSERT(( mpl_utils::set_equal<mpl_graph::vertices<some_graph>::type, mpl::vector<A,B,C,D,E,F> > ));
62
63BOOST_MPL_ASSERT_RELATION( mpl_graph::num_vertices<some_graph>::value, ==, 6 );
64
65BOOST_MPL_ASSERT_RELATION( mpl_graph::num_edges<some_graph>::value, ==, 6 );
66
67
68int main(int argc, char* argv[])
69{
70 return 0;
71}
72