src/graph/ds/graph_c/lib.hpp
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include "../../../util/traits/others/lib.hpp" | ||
| 4 | |||
| 5 | namespace tifa_libs { | ||
| 6 | namespace graph_info_impl_ { | ||
| 7 | struct graph_info_tag_base {}; | ||
| 8 | template <class... Info> | ||
| 9 | requires(std::derived_from<Info, graph_info_tag_base> && ...) | ||
| 10 | struct graph_tag_base : Info... { | ||
| 11 | 2325 | CEXP graph_tag_base(auto&&... args) NE : Info(std::forward<decltype(args)>(args)...)... {} | |
| 12 | |||
| 13 | protected: | ||
| 14 | 335007334 | CEXP void add_arc(auto&&... args) NE { (Info::add_arc(std::forward<decltype(args)>(args)...), ...); } | |
| 15 | CEXP void del_arc(auto&&... args) NE { (Info::del_arc(std::forward<decltype(args)>(args)...), ...); } | ||
| 16 | }; | ||
| 17 | template <class T, class = std::is_void<T>::type> | ||
| 18 | struct E; | ||
| 19 | template <class T> | ||
| 20 | struct E<T, std::false_type> { | ||
| 21 | u32 to; | ||
| 22 | T cost; | ||
| 23 | CEXP E() = default; | ||
| 24 | 37552806 | CEXP E(u32 v, cT_(T) c) NE : to(v), cost(c) {} | |
| 25 | 7582698 | CEXP operator u32() CNE { return to; } | |
| 26 | }; | ||
| 27 | template <class T> | ||
| 28 | struct E<T, std::true_type> { | ||
| 29 | u32 to; | ||
| 30 | CEXP E() = default; | ||
| 31 | 283765719 | CEXP E(u32 v) NE : to(v) {} | |
| 32 | 2759381516 | CEXP operator u32() CNE { return to; } | |
| 33 | }; | ||
| 34 | } // namespace graph_info_impl_ | ||
| 35 | |||
| 36 | namespace graph_impl_ { | ||
| 37 | template <class etag_t> | ||
| 38 | struct graph : etag_t { | ||
| 39 | using Et = etag_t::val_t; | ||
| 40 | |||
| 41 | CEXP graph() = default; | ||
| 42 | 2325 | CEXPE graph(u32 n, auto&&... e_args) NE : etag_t(n, std::forward<decltype(e_args)>(e_args)...) {} | |
| 43 | |||
| 44 | 10668504 | CEXP void add_edge(u32 u, u32 v, auto&&... args) NE { etag_t::add_arc(u, v, std::forward<decltype(args)>(args)...), etag_t::add_arc(v, u, std::forward<decltype(args)>(args)...); } | |
| 45 | template <class F> | ||
| 46 | 5700296 | CEXP void foreach(u32 u, F&& f) CNE { | |
| 47 | if CEXP (std::is_void_v<Et>) | ||
| 48 |
4/4void tifa_libs::graph_impl_::graph<tifa_libs::alist_impl_::alist_tag<void> >::foreach<tifa_libs::make_graphr<tifa_libs::graph_impl_::graph<tifa_libs::alist_impl_::alist_tag<void> > >(tifa_libs::graph_impl_::graph<tifa_libs::alist_impl_::alist_tag<void> > const&)::{lambda(unsigned int, (auto:1&&)...)#1}>(unsigned int, tifa_libs::make_graphr<tifa_libs::graph_impl_::graph<tifa_libs::alist_impl_::alist_tag<void> > >(tifa_libs::graph_impl_::graph<tifa_libs::alist_impl_::alist_tag<void> > const&)::{lambda(unsigned int, (auto:1&&)...)#1}&&) const:
✓ Branch 8 taken 4313251 times.
✓ Branch 9 taken 4550793 times.
void tifa_libs::graph_impl_::graph<tifa_libs::eog_impl_::eog_tag<void> >::foreach<tifa_libs::e_bcc::e_bcc<void>(tifa_libs::graph_impl_::graph<tifa_libs::eog_impl_::eog_tag<void> > const&)::{lambda(auto:1&&, unsigned int, unsigned int)#1}::operator()<{lambda(auto:1&&, unsigned int, unsigned int)#1}&>({lambda(auto:1&&, unsigned int, unsigned int)#1}&, unsigned int, unsigned int) const::{lambda(unsigned int)#1}>(unsigned int, {lambda(auto:1&&, unsigned int, unsigned int)#1}&) const:
✓ Branch 8 taken 3075656 times.
✓ Branch 9 taken 1149503 times.
|
13089203 | for (auto v : (*this)[u]) f(v); |
| 49 | else | ||
| 50 | for (auto [v, w] : (*this)[u]) f(v, w); | ||
| 51 | 5700296 | } | |
| 52 | }; | ||
| 53 | } // namespace graph_impl_ | ||
| 54 | |||
| 55 | // clang-format off | ||
| 56 | #define CONCEPT_GRAPH(name, base) \ | ||
| 57 | template <class T> concept name##_c = specialized_from_v<T, base>; \ | ||
| 58 | template <class T> concept u##name##_c = name##_c<T> && std::same_as<TPN T::Et, void>; \ | ||
| 59 | template <class T> concept w##name##_c = name##_c<T> && !std::same_as<TPN T::Et, void> | ||
| 60 | // clang-format on | ||
| 61 | CONCEPT_GRAPH(graph, graph_impl_::graph); | ||
| 62 | |||
| 63 | } // namespace tifa_libs | ||
| 64 |