Skip to main content

would_create_cycle

Function would_create_cycle 

Source
pub fn would_create_cycle(
    existing_edges: &[(String, String)],
    from: &str,
    to: &str,
) -> bool
Expand description

Check whether adding edge from → to would create a cycle in the existing graph. Returns the cycle path if detected.

Uses DFS reachability: a cycle exists iff from is reachable from to through existing edges.