Skip to main content

has_cycle_undirected

Function has_cycle_undirected 

Source
pub fn has_cycle_undirected(graph: &[Vec<usize>]) -> bool
Expand description

Detect whether an undirected graph contains a cycle.

Pass the adjacency list and edges must already be reciprocal (i.e., for any edge u -- v you must include both v in graph[u] and u in graph[v]).