3.1.1. pywhy_graphs.algorithms.is_valid_mec_graph#

pywhy_graphs.algorithms.is_valid_mec_graph(G, on_error: str = 'raise') bool[source]#

Check G is a valid PAG.

A valid CPDAG/PAG is one where each pair of nodes have at most one edge between them and the internal graph of directed edges do not form cycles.

Parameters:
GPAG | CPDAG

The PAG or CPDAG.

on_errorstr

Whether to raise an error if the graph is non-compliant. Default is ‘raise’. Other options are ‘ignore’.

Returns:
bool

Whether G is a valid PAG or CPDAG.

Notes

This function does not check whether or not the PAG, or CPDAG are valid in the sense that the construction of the PAG/CPDAG was constrained to not contain any directed edge cycles.