is_minimal_d_separator#
- is_minimal_d_separator(G, x, y, z, *, included=None, restricted=None)[source]#
Determine if
zis a minimal d-separator forxandy.A d-separator,
z, in a DAG is a set of nodes that blocks all paths from nodes in setxto nodes in sety. A minimal d-separator is a d-separatorzsuch that removing any subset of nodes makes it no longer a d-separator.Note: This function checks whether
zis a d-separator AND is minimal. One can use the functionis_d_separatorto only check ifzis a d-separator. See examples below.- Parameters:
- Gnx.DiGraph
A NetworkX DAG.
- xnode | set
A node or set of nodes in the graph.
- ynode | set
A node or set of nodes in the graph.
- znode | set
The node or set of nodes to check if it is a minimal d-separating set. The function
is_d_separator()is called inside this function to verify thatzis in fact a d-separator.- includedset | node | None
A node or set of nodes which must be included in the found separating set, default is
None, which means the empty set.- restrictedset | node | None
Restricted node or set of nodes to consider. Only these nodes can be in the found separating set, default is
Nonemeaning all nodes inG.
- Returns:
- bool
Whether or not the set
zis a minimal d-separator subject torestrictednodes andincludednode constraints.
- Raises:
- NetworkXError
Raises a
NetworkXErrorif the input graph is not a DAG.- NodeNotFound
If any of the input nodes are not found in the graph, a
NodeNotFoundexception is raised.
Notes
This function works on verifying that a set is minimal and d-separating between two nodes. Uses criterion (a), (b), (c) on page 4 of [1]. a) closure(
x) andyare disjoint. b)zcontains all nodes fromincludedand is contained in therestrictednodes and in the union of ancestors ofx,y, andincluded. c) the nodes inznot inincludedare contained in both closure(x) and closure(y). The closure of a set is the set of nodes connected to the set by a directed path in G.The complexity is \(O(m)\), where \(m\) stands for the number of edges in the subgraph of G consisting of only the ancestors of
xandy.For full details, see [1].
References
Examples
>>> G = nx.path_graph([0, 1, 2, 3], create_using=nx.DiGraph) >>> G.add_node(4) >>> nx.is_minimal_d_separator(G, 0, 2, {1}) True >>> # since {1} is the minimal d-separator, {1, 3, 4} is not minimal >>> nx.is_minimal_d_separator(G, 0, 2, {1, 3, 4}) False >>> # alternatively, if we only want to check that {1, 3, 4} is a d-separator >>> nx.is_d_separator(G, 0, 2, {1, 3, 4}) True