6 #include <brigand/brigand.hpp>
13 template <
typename Source,
typename Destination,
typename Weight =
int32_t<1>>
15 using source = Source;
16 using destination = Destination;
17 using weight = Weight;
20 template <
int Source,
int Destination,
int Weight = 1>
25 template <
typename Source,
typename Destination,
typename Weight>
32 template <
typename Source,
typename Destination,
typename Weight>
34 using type = Destination;
39 template <
typename Source,
typename Destination,
typename Weight>
44 template <
typename State,
typename Element>
47 template <
typename State,
typename Source,
typename Destination,
50 using source =
typename if_<found<State, std::is_same<pin<Source>, _1>>,
51 list<>, list<Source>>::type;
53 typename if_<found<State, std::is_same<pin<Destination>, _1>>, list<>,
54 list<Destination>>::type;
55 using type = append<State, source, destination>;
58 template <
class E,
class S,
class = std::
nullptr_t>
60 template <
class E,
class S>
64 template <
class E,
class D,
class =
void>
66 template <
class E,
class D>
68 E, D,
Requires<std::is_same<typename E::destination, D>::value>>
71 template <
class E,
class S,
class D>
73 template <
template <
class...>
class E,
class S,
class D,
class W>
76 template <
class edgeList>
80 template <
class Graph,
class S,
class D>
82 template <
class S,
class D,
class edgeList>
83 struct get_edge_impl<
digraph<edgeList>, S, D> {
84 using type = find<edgeList, has_source_and_destination<_1, pin<S>, pin<D>>>;
89 template <
class Graph,
class S,
class D>
91 template <
class S,
class D,
class edgeList>
92 struct has_edge_impl<digraph<edgeList>, S, D>
93 : found<edgeList, has_source_and_destination<_1, pin<S>, pin<D>>> {};
96 template <
class Graph>
98 template <
class edgeList>
103 template <
class Graph>
105 template <
class edgeList>
111 template <
class T,
template <
class...>
class F,
class... Es>
113 template <
template <
class...>
class VertexSeq,
class... Vertices,
class... Es,
114 template <
class...>
class F>
116 using type = brigand::list<
117 brigand::filter<brigand::list<Es...>, F<brigand::_1, pin<Vertices>>>...>;
120 template <
template <
class...>
class List,
class... edges>
123 using edge_list = list<edges...>;
124 static_assert(is_set<edge_list>::value,
125 "Cannot have repeated edges in a digraph");
126 using unique_vertex_list =
128 using vertex_count = size<unique_vertex_list>;
129 using edge_count = uint32_t<
sizeof...(edges)>;
138 static digraph<::brigand::remove<
140 detail::get_edge_impl<
digraph<List<edges...>>,
typename E::source,
141 typename E::destination>>>
142 erase(brigand::type_<E>);
146 remove<list<edges...>,
147 detail::get_edge_impl<
digraph<List<edges...>>,
typename E::source,
148 typename E::destination>>,
150 insert(::brigand::type_<E>);
154 template <
class Graph,
class S,
class D>
155 using has_edge = ::brigand::detail::has_edge_impl<Graph, S, D>;
164 template <
class Graph,
class S,
class D>
165 using has_edge = typename ::brigand::lazy::has_edge<Graph, S, D>::type;
168 template <
class Graph,
class S,
class D>
169 using get_edge = ::brigand::detail::get_edge_impl<Graph, S, D>;
172 template <
class Graph,
class S,
class D>
173 using get_edge = typename ::brigand::lazy::get_edge<Graph, S, D>;
175 template <
class Graph,
class Vertex>
176 using outgoing_edges =
at<
typename Graph::adjacency_list::type,
177 index_of<typename Graph::unique_vertex_list, Vertex>>;
179 template <
class Graph,
class Vertex>
180 using ingoing_edges =
at<
typename Graph::ingoing_list::type,
181 index_of<typename Graph::unique_vertex_list, Vertex>>;
183 template <
class Graph>
184 using vertex_count = size<typename Graph::unique_vertex_list>;
186 template <
class Graph>
187 using edge_count = size<typename Graph::edge_list>;