GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 100.0% 16 / 0 / 16
Functions: 100.0% 2 / 0 / 2
Branches: 83.3% 10 / 0 / 12

src/graph/path/lib.hpp
Line Branch Exec Source
1 #pragma once
2
3 #include "../ds/graph_c/lib.hpp"
4
5 namespace tifa_libs {
6
7 template <graph_c G>
8 16 CEXP auto path(G CR g, u32 from, u32 to) NE {
9 16 std::optional ret{vecu{}};
10 16 bool failed = true;
11 2158949 auto dfs = [&](auto&& dfs, u32 now, u32 fa) NE -> void {
12 2158933 ret->push_back(now);
13
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 2158917 times.
2158933 if (now == to) {
14 16 failed = false;
15 16 return;
16 }
17
2/2
✓ Branch 6 taken 4067552 times.
✓ Branch 7 taken 1658515 times.
5726067 for (auto v : g[now]) {
18 4067552 u32 to = 0;
19
2/2
✓ Branch 1 taken 1908635 times.
✓ Branch 2 taken 2158917 times.
4067552 if ((to = (u32)v) == fa) continue;
20
2/2
✓ Branch 1 taken 500402 times.
✓ Branch 2 taken 1658515 times.
2158917 if (dfs(dfs, to, now); !failed) return;
21 }
22
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1658515 times.
1658515 if (!failed) return;
23 1658515 ret->pop_back();
24 };
25
1/2
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
16 if (dfs(dfs, from, -1_u32); failed) ret = std::nullopt;
26 16 return ret;
27 }
28
29 } // namespace tifa_libs
30