Skip to content

Commit

Permalink
add docs now
Browse files Browse the repository at this point in the history
  • Loading branch information
lrvideckis committed Nov 27, 2024
1 parent b99456e commit 9902888
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions library/graphs/functional_graph_processor.hpp
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<int> a(n);
for (int i = 0; i < n; i++) a[i] = rnd(0, n - 1);
auto [t, cycle] = func_graph(a);
Expand Down

0 comments on commit 9902888

Please sign in to comment.