ragraph.utils#

Graph handling utilities module.

Module Contents#

Functions#

select_nodes(→ List[ragraph.node.Node])

Select specific nodes from this graph in a structured order.

get_up_to_depth(→ Generator[ragraph.node.Node, None, None])

Get nodes up to a certain depth with bus nodes at the start of child lists.

is_dependent(→ bool)

Check if a node is dependent on the lead node kind.

ragraph.utils.select_nodes(graph, node_kinds: List[str], edge_kinds: List[str], depth: int, selection_mode: str) List[ragraph.node.Node]#

Select specific nodes from this graph in a structured order.

Parameters:
  • graph – Graph to fetch data from.

  • node_kinds – The kind of nodes to be selected.

  • edge_kinds – The kind of edges to be selected.

  • depth – The maximum depth of node to be selected.

  • selection_mode – The selection mode. Either ‘dependent’ or ‘independent’.

Note

The selection mode argument determines how nodes of different kinds are selected. If the selection mode is set to ‘dependent’, the first node kind in the node_kinds list is considered to be the ‘lead node kind’. Nodes of different kind than the lead node kind, are only selected if they have a dependency with at least one of the selected nodes of the lead node kind. If the selection mode is set to ‘independent’ this dependency condition is dropped.

ragraph.utils.get_up_to_depth(roots: List[ragraph.node.Node], depth: int) Generator[ragraph.node.Node, None, None]#

Get nodes up to a certain depth with bus nodes at the start of child lists.

ragraph.utils.is_dependent(graph, lead_nodes: List[ragraph.node.Node], node: ragraph.node.Node, edge_kinds=Set[str]) bool#

Check if a node is dependent on the lead node kind.

E.g. an edge of the allowed kinds exists to or from the lead nodes.