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 #ifndef BOOST_MSM_MPL_GRAPH_DETAIL_INCIDENCE_LIST_GRAPH_IPP_INCLUDED
7 #define BOOST_MSM_MPL_GRAPH_DETAIL_INCIDENCE_LIST_GRAPH_IPP_INCLUDED
9 // these metafunctions provide the metadata structures needed by the public interface
12 #include <boost/mpl/map.hpp>
13 #include <boost/mpl/vector.hpp>
14 #include <boost/mpl/copy.hpp>
15 #include <boost/mpl/vector.hpp>
16 #include <boost/mpl/next.hpp>
17 #include <boost/mpl/front.hpp>
18 #include <boost/mpl/back.hpp>
19 #include <boost/mpl/deref.hpp>
20 #include <boost/mpl/if.hpp>
21 #include <boost/mpl/size.hpp>
22 #include <boost/mpl/void.hpp>
23 #include <boost/mpl/erase_key.hpp>
24 #include <boost/mpl/has_key.hpp>
25 #include <boost/mpl/inserter.hpp>
26 #include <boost/mpl/back_inserter.hpp>
27 #include <boost/mpl/set.hpp>
28 #include <boost/mpl/insert.hpp>
29 #include <boost/mpl/transform.hpp>
30 #include <boost/mpl/pair.hpp>
31 #include <boost/mpl/size.hpp>
32 #include <boost/mpl/fold.hpp>
33 #include <boost/mpl/transform.hpp>
34 #include <boost/mpl/at.hpp>
35 #include <boost/mpl/push_back.hpp>
36 #include <boost/mpl/filter_view.hpp>
37 #include <boost/mpl/transform_view.hpp>
38 #include <boost/mpl/equal.hpp>
39 #include <boost/type_traits.hpp>
47 // tag to identify this graph implementation (not defined)
48 struct incidence_list_tag;
51 template<typename EST> struct fetch_edge :
53 template<typename EST> struct fetch_source :
54 mpl::deref<typename mpl::next<typename mpl::begin<EST>::type>::type> {};
55 template<typename EST> struct fetch_target :
58 // Edge->Target map for an Source for out_*, adjacent_vertices
59 template<typename Source, typename ESTSequence>
60 struct produce_out_map<incidence_list_tag, Source, ESTSequence> :
61 mpl::fold<typename mpl::filter_view<ESTSequence, boost::is_same<fetch_source<mpl::_1>,Source> >::type,
63 mpl::insert<mpl::_1,mpl::pair<fetch_edge<mpl::_2>,fetch_target<mpl::_2> > > >
66 // Edge->Source map for a Target for in_*, degree
67 template<typename Target, typename ESTSequence>
68 struct produce_in_map<incidence_list_tag, Target, ESTSequence> :
69 mpl::fold<typename mpl::filter_view<ESTSequence,
70 boost::is_same<fetch_target<mpl::_1>,Target> >::type,
72 mpl::insert<mpl::_1,mpl::pair<fetch_edge<mpl::_2>,fetch_source<mpl::_2> > > >
75 // Edge->pair<Source,Target> map for source, target
76 template<typename ESTSequence>
77 struct produce_edge_st_map<incidence_list_tag, ESTSequence> :
78 mpl::fold<ESTSequence,
80 mpl::insert<mpl::_1,mpl::pair<fetch_edge<mpl::_2>,
81 mpl::pair<fetch_source<mpl::_2>,
82 fetch_target<mpl::_2> > > > >
84 // Vertex set for VertexListGraph
85 template<typename ESTSequence>
86 struct produce_vertex_set<incidence_list_tag, ESTSequence> :
87 mpl::fold<ESTSequence,
88 typename mpl::fold<ESTSequence,
90 mpl::insert<mpl::_1,fetch_target<mpl::_2> >
92 mpl::insert<mpl::_1, fetch_source<mpl::_2> > >
94 // Edge set for EdgeListGraph
95 template<typename ESTSequence>
96 struct produce_edge_set<incidence_list_tag, ESTSequence> :
97 mpl::fold<ESTSequence,
99 mpl::insert<mpl::_1,fetch_edge<mpl::_2> > >
106 #endif // BOOST_MSM_MPL_GRAPH_DETAIL_INCIDENCE_LIST_GRAPH_IPP_INCLUDED