graph.hasUndirectedCycle

pyagrum.graph.hasUndirectedCycle(g)

Whether the edges of a graph (family E) contain a cycle.

Parameters:

g (UndiGraph | MixedGraph | PDAG | ChainGraph | CPDAG | MPDAG | EssentialGraph) – the graph (its arcs are ignored)

Returns:

True if a cycle of edges exists

Return type:

bool

Example

import pyagrum as gum
import pyagrum.graph as gg

gg.hasUndirectedCycle(gum.fastUndiGraph("A-B-C-A"))
# True
gg.hasUndirectedCycle(gum.fastMixedGraph("A-B-C->A"))  # the arcs are ignored
# False