4.2. pywhy_graphs.algorithms.semi_directed_paths.is_semi_directed_path#

pywhy_graphs.algorithms.semi_directed_paths.is_semi_directed_path(G, nodes)[source]#

Returns True if and only if nodes form a semi-directed path in G.

A semi-directed path in a graph is a nonempty sequence of nodes in which no node appears more than once in the sequence, each adjacent pair of nodes in the sequence is adjacent in the graph and where each pair of adjacent nodes does not contain a directed endpoint in the direction towards the start of the sequence.

That is (a -> b o-> c <-> d -> e) is not a semi-directed path from a to e because d *-> c is a directed endpoint in the direction towards a.

Parameters:
Ggraph

A mixed-edge graph.

nodeslist

A list of one or more nodes in the graph G.

Returns:
bool

Whether the given list of nodes represents a semi-directed path in G.

Notes

This function is very similar to networkx’s networkx.algorithms.simple_paths.is_simple_path() function.