Skip to content

Commit

Permalink
Added docstring
Browse files Browse the repository at this point in the history
Signed-off-by: Aryan Roy <[email protected]>
  • Loading branch information
aryan26roy committed Aug 15, 2024
1 parent 7f01c98 commit 6ad4765
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions pywhy_graphs/algorithms/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,23 @@ def all_vstructures(G: nx.DiGraph, as_edges: bool = False):


def _check_back_arrow(G: ADMG, X, Y: set):
"""Retrieve all the neigbors of X that do not have
an arrow pointing back to it.
Parameters
----------
G : DiGraph
A directed graph.
X : Node
Y : Set
A set of neigbors of X.
Returns
-------
out : set
A set of all the neighbors of X that do not have an arrow pointing
back to it.
"""
out = set()

for elem in Y:
Expand All @@ -872,6 +888,20 @@ def _check_back_arrow(G: ADMG, X, Y: set):


def _get_X_neighbors(G, X: set):
"""Retrieve all the neigbors of X when X has more than one element.
Parameters
----------
G : DiGraph
A directed graph.
X : Set
Returns
-------
out : set
A set of all the neighbors of X.
"""


out = set()

Expand All @@ -890,6 +920,24 @@ def _get_X_neighbors(G, X: set):


def _recursively_find_pd_paths(G, X, paths, Y):
"""Recursively finds all the possibly directed paths for a given
graph.
Parameters
----------
G : DiGraph
A directed graph.
X : Set
Source.
Y : Set
Destination
Returns
-------
out : set
A set of all the possibly directed paths.
"""


counter = 0
new_paths = set()
Expand Down Expand Up @@ -934,6 +982,22 @@ def _recursively_find_pd_paths(G, X, paths, Y):


def possibly_directed_path(G, X: Optional[Set] = None, Y: Optional[Set] = None):
"""Find all the possibly directed paths in a graph.
Parameters
----------
G : DiGraph
A directed graph.
X : Set
Source.
Y : Set
Destination
Returns
-------
out : set
A set of all the possibly directed paths.
"""

if isinstance(X, set):
x_neighbors = _get_X_neighbors(G, X)
Expand Down

0 comments on commit 6ad4765

Please sign in to comment.