Skip to content

@graphty/algorithms / index / hasCycle

Function: hasCycle() ​

hasCycle(g): boolean

Defined in: indexed/dfs.ts:188

Whether the graph has a cycle. Directed: a DFS back arc. Undirected: an edge closing a loop in a union-find forest. A self-loop is a cycle; a parallel pair is not -- the graph is read as simple, the adjacent-skip idiom of graph-format design section 3.5.

Parameters ​

g ​

AdjacencyView

The adjacency to test

Returns ​

boolean

True when a cycle exists