src/graph/scc/v_bcc/lib.hpp
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include "../../ds/alist/lib.hpp" | ||
| 4 | |||
| 5 | namespace tifa_libs { | ||
| 6 | |||
| 7 | template <bool get_vcut = false, bool get_ecut = false, bool get_belongs = true> | ||
| 8 | struct v_bcc { | ||
| 9 | static_assert(!get_ecut || (!get_vcut && !get_belongs)); | ||
| 10 | vecu dfn, low; | ||
| 11 | vvecu belongs; | ||
| 12 | vecb vcut; | ||
| 13 | vecptu ecut; | ||
| 14 | |||
| 15 | //! g should be undirect | ||
| 16 | 510 | CEXP v_bcc(graph_c auto CR g) NE : dfn(g.vsize()), low(g.vsize()) { | |
| 17 | 40 | if CEXP (get_vcut) vcut = vecb(g.vsize()); | |
| 18 | 40 | if CEXP (get_ecut) ecut.reserve(g.vsize()); | |
| 19 | 102 | vecu stk; | |
| 20 | 102 | u32 cnt = 0, start; | |
| 21 | 5238785 | auto tarjan = [&](auto&& f, u32 u, u32 fa) -> void { | |
| 22 | 5238785 | u32 son = 0; | |
| 23 | 5238785 | if CEXP (low[u] = dfn[u] = ++cnt; get_belongs) stk.push_back(u); | |
| 24 |
6/6void tifa_libs::v_bcc<false, false, true>::v_bcc<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(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:
✓ Branch 6 taken 11006758 times.
✓ Branch 7 taken 5146169 times.
void tifa_libs::v_bcc<false, true, false>::v_bcc<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(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:
✓ Branch 6 taken 258186 times.
✓ Branch 7 taken 46308 times.
void tifa_libs::v_bcc<true, false, false>::v_bcc<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(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:
✓ Branch 6 taken 258186 times.
✓ Branch 7 taken 46308 times.
|
16761915 | for (bool ecut_flag = false; auto v : g[u]) // NOLINT(misc-const-correctness) |
| 25 |
6/6void tifa_libs::v_bcc<false, false, true>::v_bcc<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(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:
✓ Branch 2 taken 4338890 times.
✓ Branch 3 taken 6667868 times.
void tifa_libs::v_bcc<false, true, false>::v_bcc<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(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:
✓ Branch 2 taken 46268 times.
✓ Branch 3 taken 211918 times.
void tifa_libs::v_bcc<true, false, false>::v_bcc<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(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:
✓ Branch 2 taken 46268 times.
✓ Branch 3 taken 211918 times.
|
11523130 | if (!dfn[v]) { |
| 26 |
3/6void tifa_libs::v_bcc<false, false, true>::v_bcc<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(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:
✓ Branch 2 taken 4338890 times.
✗ Branch 3 not taken.
void tifa_libs::v_bcc<false, true, false>::v_bcc<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(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:
✓ Branch 2 taken 46268 times.
✗ Branch 3 not taken.
void tifa_libs::v_bcc<true, false, false>::v_bcc<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(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:
✓ Branch 2 taken 46268 times.
✗ Branch 3 not taken.
|
4431426 | ++son, f(f, v, u), low[u] = min(low[u], low[v]); |
| 27 | if CEXP (get_ecut) { | ||
| 28 |
3/4✓ Branch 3 taken 326 times.
✓ Branch 4 taken 45942 times.
✓ Branch 6 taken 326 times.
✗ Branch 7 not taken.
|
46268 | if (low[v] > dfn[u]) ecut.emplace_back(v, u); |
| 29 | } else { | ||
| 30 |
4/4void tifa_libs::v_bcc<false, false, true>::v_bcc<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(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:
✓ Branch 3 taken 2302059 times.
✓ Branch 4 taken 2036831 times.
void tifa_libs::v_bcc<true, false, false>::v_bcc<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(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:
✓ Branch 3 taken 365 times.
✓ Branch 4 taken 45903 times.
|
4385158 | if (low[v] >= dfn[u]) { |
| 31 | if CEXP (get_vcut) | ||
| 32 |
3/4✓ Branch 0 taken 320 times.
✓ Branch 1 taken 45 times.
✓ Branch 3 taken 320 times.
✗ Branch 4 not taken.
|
365 | if (u != start) vcut[u] = true; |
| 33 | if CEXP (get_belongs) { | ||
| 34 | 2302059 | vecu res; | |
| 35 | u32 p; | ||
| 36 |
1/2✓ Branch 2 taken 4338890 times.
✗ Branch 3 not taken.
|
4338890 | do res.push_back(p = stk.back()), stk.pop_back(); |
| 37 |
2/2✓ Branch 1 taken 2036831 times.
✓ Branch 2 taken 2302059 times.
|
4338890 | while (v != p); |
| 38 |
2/4✓ Branch 1 taken 2302059 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 2302059 times.
✗ Branch 6 not taken.
|
2302059 | res.push_back(u), belongs.emplace_back(std::move(res)); |
| 39 | 2302059 | } | |
| 40 | } | ||
| 41 | } | ||
| 42 | } else { | ||
| 43 | if CEXP (get_ecut) { | ||
| 44 |
5/6✓ Branch 1 taken 46268 times.
✓ Branch 2 taken 165650 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 46268 times.
✓ Branch 5 taken 165650 times.
✓ Branch 6 taken 46268 times.
|
211918 | if (v != fa || ecut_flag) low[u] = min(low[u], dfn[v]); |
| 45 | 46268 | else ecut_flag = true; | |
| 46 |
4/4void tifa_libs::v_bcc<false, false, true>::v_bcc<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(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:
✓ Branch 1 taken 2328502 times.
✓ Branch 2 taken 4339366 times.
void tifa_libs::v_bcc<true, false, false>::v_bcc<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(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:
✓ Branch 1 taken 165650 times.
✓ Branch 2 taken 46268 times.
|
6879786 | } else if (v != fa) low[u] = min(low[u], dfn[v]); |
| 47 | } | ||
| 48 | if CEXP (get_vcut) | ||
| 49 |
5/6✓ Branch 0 taken 40 times.
✓ Branch 1 taken 46268 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 36 times.
✓ Branch 5 taken 4 times.
✗ Branch 6 not taken.
|
46308 | if (u == start && son >= 2) vcut[u] = true; |
| 50 | if CEXP (get_belongs) | ||
| 51 |
6/8✓ Branch 0 taken 807279 times.
✓ Branch 1 taken 4338890 times.
✓ Branch 2 taken 736075 times.
✓ Branch 3 taken 71204 times.
✓ Branch 5 taken 736075 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 736075 times.
✗ Branch 9 not taken.
|
6618319 | if (!~fa && !son) belongs.push_back({u}); |
| 52 | }; | ||
| 53 |
6/6void tifa_libs::v_bcc<false, false, true>::v_bcc<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(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:
✓ Branch 1 taken 5146169 times.
✓ Branch 2 taken 22 times.
void tifa_libs::v_bcc<false, true, false>::v_bcc<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(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:
✓ Branch 1 taken 46308 times.
✓ Branch 2 taken 40 times.
void tifa_libs::v_bcc<true, false, false>::v_bcc<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(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:
✓ Branch 1 taken 46308 times.
✓ Branch 2 taken 40 times.
|
5238887 | flt_ (u32, i, 0, g.vsize()) |
| 54 |
6/6void tifa_libs::v_bcc<false, false, true>::v_bcc<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(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:
✓ Branch 1 taken 807279 times.
✓ Branch 2 taken 4338890 times.
void tifa_libs::v_bcc<false, true, false>::v_bcc<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(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:
✓ Branch 1 taken 40 times.
✓ Branch 2 taken 46268 times.
void tifa_libs::v_bcc<true, false, false>::v_bcc<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(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:
✓ Branch 1 taken 40 times.
✓ Branch 2 taken 46268 times.
|
5238785 | if (!dfn[i]) tarjan(tarjan, start = i, -1_u32); |
| 55 | 102 | } | |
| 56 | }; | ||
| 57 | |||
| 58 | } // namespace tifa_libs | ||
| 59 |