Current section

Files

Jump to
yog src yog@properties@cyclicity.erl
Raw

src/yog@properties@cyclicity.erl

-module(yog@properties@cyclicity).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/yog/properties/cyclicity.gleam").
-export([is_acyclic/1, is_cyclic/1]).
-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.
?MODULEDOC(" Graph cyclicity and Directed Acyclic Graph (DAG) analysis.\n").
-file("src/yog/properties/cyclicity.gleam", 13).
?DOC(
" Checks if the graph is a Directed Acyclic Graph (DAG) or has no cycles if undirected.\n"
"\n"
" For directed graphs, a cycle exists if there is a path from a node back to itself.\n"
" For undirected graphs, a cycle exists if there is a path of length >= 3 from a node back to itself,\n"
" or a self-loop.\n"
"\n"
" **Time Complexity:** O(V + E)\n"
).
-spec is_acyclic(yog@model:graph(any(), any())) -> boolean().
is_acyclic(Graph) ->
yog@traversal:is_acyclic(Graph).
-file("src/yog/properties/cyclicity.gleam", 22).
?DOC(
" Checks if the graph contains at least one cycle.\n"
"\n"
" Logical opposite of `is_acyclic`.\n"
"\n"
" **Time Complexity:** O(V + E)\n"
).
-spec is_cyclic(yog@model:graph(any(), any())) -> boolean().
is_cyclic(Graph) ->
yog@traversal:is_cyclic(Graph).