Skip to content

DAG Parsing

bigtree.dag.parsing

get_path_dag

get_path_dag(from_node, to_node)

Get path from origin node to destination node. Path is inclusive of origin and destination nodes.

Examples:

>>> from bigtree import DAGNode, get_path_dag
>>> a = DAGNode("a")
>>> b = DAGNode("b")
>>> c = DAGNode("c")
>>> d = DAGNode("d")
>>> a >> c
>>> b >> c
>>> c >> d
>>> a >> d
>>> get_path_dag(a, c)
[[DAGNode(a, ), DAGNode(c, )]]
>>> get_path_dag(a, d)
[[DAGNode(a, ), DAGNode(c, ), DAGNode(d, )], [DAGNode(a, ), DAGNode(d, )]]
>>> get_path_dag(a, b)
Traceback (most recent call last):
    ...
bigtree.utils.exceptions.exceptions.TreeError: It is not possible to go to DAGNode(b, )

Parameters:

Name Type Description Default
from_node T

start point of path, node to travel from

required
to_node T

end point of path, node to travel to

required

Returns:

Type Description
list[list[T]]

Possible paths from origin to destination node from the same DAG