From 990288844356a75f13151ddac576d8d4861e8413 Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Wed, 27 Nov 2024 14:21:53 -0600 Subject: [PATCH] add docs now --- library/graphs/functional_graph_processor.hpp | 11 +++++++++++ .../handmade_tests/functional_graph.test.cpp | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/library/graphs/functional_graph_processor.hpp b/library/graphs/functional_graph_processor.hpp index a725d403..f0931455 100644 --- a/library/graphs/functional_graph_processor.hpp +++ b/library/graphs/functional_graph_processor.hpp @@ -1,4 +1,15 @@ #pragma once +//! https://github.com/Aeren1564/Algorithms/blob/master/Algorithm_Implementations_Cpp/Graph_Theory/Special_Graphs/functional_graph_processor.sublime-snippet +//! @code +//! // 0 <= a[i] < n +//! auto [t, cycle] = func_graph(a); +//! if (auto id = t[v].cyc_pos) +//! assert(v == cycle[id->first][id->second]); +//! @endcode +//! t[v].root_of = first reachable node in a cycle +//! t[v].childs = forest of reversed edges not in cycles +//! @time O(n) +//! @space O(n) struct func_graph { struct node { int root_of; diff --git a/tests/library_checker_aizu_tests/handmade_tests/functional_graph.test.cpp b/tests/library_checker_aizu_tests/handmade_tests/functional_graph.test.cpp index 6564951b..a9e651ab 100644 --- a/tests/library_checker_aizu_tests/handmade_tests/functional_graph.test.cpp +++ b/tests/library_checker_aizu_tests/handmade_tests/functional_graph.test.cpp @@ -155,7 +155,7 @@ struct functional_graph_processor { int main() { cin.tie(0)->sync_with_stdio(0); for (int num_tests = 1000; num_tests--;) { - int n = rnd(1, 1000); + int n = rnd(1, 10000); vector a(n); for (int i = 0; i < n; i++) a[i] = rnd(0, n - 1); auto [t, cycle] = func_graph(a);