raesl.plot.utils#

RaESL plotting utility functions.

Module Contents#

Functions#

get_component_function_dicts(→ Tuple[Dict[str, ...)

Get two dictionaries from component node names to lists of transformation and

crawl_descendants(→ Tuple[List[ragraph.node.Node], ...)

Walk down the decomposition tree of a node, add its children and create

get_neighbors(→ Set[ragraph.node.Node])

Get neighbors of a node within the graph.

get_paths_between_all(→ List[List[str]])

Compute paths between nodes. Based on depth first search.

get_paths(→ List[List[str]])

Collection all paths (list of node names) between the source node and the set of

select_components_for_function_path(...)

Select components that belong to a certain level within the decomposition

add_level(graph, sliced, parents)

Add a level to the sliced graph based on the hierarchy in the source graph.

rebuild_hierarchical_structure(graph, sliced)

Rebuilding the hierarchical structure within the sliced graph.

get_all_descendants(→ Set[ragraph.node.Node])

Get all descendants from a list of provided nodes.

check_comp_func_pairs(points)

Check of for all points the provided components functions pairs are consistent.

check_tree_disjunction(nodes)

Check if list of nodes are not part of each others descendants.

check_start_and_end_points(start_points, end_points)

Check start and end points for consistency.

get_function_tree(→ Tuple[Set[ragraph.node.Node], ...)

Walk down the traceability tree of a node.

migrate_edges_between_variables(→ List[ragraph.edge.Edge])

Migrate edges between variables up into the decomposition tree.

has_mapping_dependency(→ bool)

Check if a node is mapped to any node in a list of nodes.

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

Filter nodes for displaying a multi-domain-matrix.

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.

raesl.plot.utils.get_component_function_dicts(graph: ragraph.graph.Graph) Tuple[Dict[str, List[ragraph.node.Node]], Dict[str, List[ragraph.node.Node]]]#

Get two dictionaries from component node names to lists of transformation and goal function nodes.

Arguments

graph: Instantiated ESL graph.

Returns

Dictionaries from component node names to transformation and goal function nodes.

raesl.plot.utils.crawl_descendants(node: ragraph.node.Node, max_depth: int) Tuple[List[ragraph.node.Node], List[ragraph.edge.Edge]]#

Walk down the decomposition tree of a node, add its children and create composition dependencies accordingly.

Parameters:
  • node – The parent node to unfold.

  • max_depth – Max depth to unfold nodes to (absolute depth w.r.t. root).

Returns:

List of (additionally) crawled nodes and “composition_dependency” edges.

Note

Since we explicitly need to figure out which (partial) hierarchies to display using Graphviz, we recreate those parts of the hierarchy using explicit “composition dependency” Edge objects in the preprocessing step using ragraph.graph.GraphView objects.

raesl.plot.utils.get_neighbors(graph: ragraph.graph.Graph, root: ragraph.node.Node, node: ragraph.node.Node, node_kinds: Set[str], degree: int = 1) Set[ragraph.node.Node]#

Get neighbors of a node within the graph.

Parameters:
  • graph – Instantiated ESL graph.

  • root – The root node for which the nodes must be sought up to the given degree.

  • node – The node for which the direct neighbors must be collected.

  • node_kinds – The kinds of the neighbor nodes that must be collected.

  • degree – The degree up to which neighbors must be collected (neighbors of

  • 1. (neighbors). Defaults to) –

Returns

Set of neighbors.

raesl.plot.utils.get_paths_between_all(sources: List[ragraph.node.Node], targets: List[ragraph.node.Node], edges: List[ragraph.edge.Edge]) List[List[str]]#

Compute paths between nodes. Based on depth first search.

Parameters:
  • sources – List of starting nodes of paths.

  • targets – Set of ending nodes of path.

  • edges – List of edges between nodes.

Yields:

List of lists of node names.

raesl.plot.utils.get_paths(source: ragraph.node.Node, edges: Dict[ragraph.node.Node, Dict[ragraph.node.Node, ragraph.edge.Edge]], targets: Set[ragraph.node.Node], visited: List[ragraph.node.Node] = []) List[List[str]]#

Collection all paths (list of node names) between the source node and the set of target nodes.

Parameters:
  • source – The source node where all paths should start.

  • edges – Dictionary of Node to Node to Edge. Contains the edges to be considered when searching for paths.

  • targets – Set of node where the paths should end.

  • visited – List of nodes already visited. Required to prevent running in cycles.

Returns:

List of lists of node names.

raesl.plot.utils.select_components_for_function_path(graph: ragraph.graph.Graph, start_points: List[Tuple[ragraph.node.Node, List[ragraph.node.Node]]], end_points: List[Tuple[ragraph.node.Node, List[ragraph.node.Node]]], levels: int) List[ragraph.node.Node]#

Select components that belong to a certain level within the decomposition structure to draw a functional path.

Parameters:
  • graph – Instantiated ESL graph.

  • start_points – List of tuples that contain the component node and list of function nodes that serve as a starting point of the function chains.

  • end_points – List of Tuples that contain the component node and list of functions that nodes server.

  • levels – Number of levels to decompose intermediate components into. This number is relative to the maximum of the depth of the start

  • node. (node and end) –

Note

Components that are a descendant of the start or end component node of the function path are excluded.

raesl.plot.utils.add_level(graph: ragraph.graph.Graph, sliced: ragraph.graph.Graph, parents: Set[ragraph.node.Node])#

Add a level to the sliced graph based on the hierarchy in the source graph.

Parameters:
  • graph – Instantiated ESL graph.

  • sliced – Sliced data graph.

Note

Creates deepcopies of child nodes to preserve the original data structure.

raesl.plot.utils.rebuild_hierarchical_structure(graph: ragraph.graph.Graph, sliced: ragraph.graph.Graph)#

Rebuilding the hierarchical structure within the sliced graph.

Parameters:
  • graph – Instantiated ESL graph.

  • sliced – Sliced data graph.

Note

Creates deepcopies of child nodes to preserve the original data structure.

raesl.plot.utils.get_all_descendants(nodes: List[ragraph.node.Node]) Set[ragraph.node.Node]#

Get all descendants from a list of provided nodes.

Parameters:

nodes – List of nodes for which the descendants must be found.

Returns:

Set of nodes containing all descendants of the provided nodes.

raesl.plot.utils.check_comp_func_pairs(points: List[Tuple[ragraph.node.Node, List[ragraph.node.Node]]])#

Check of for all points the provided components functions pairs are consistent.

Parameters:

points – List of points for which the consistency must be checked.

Raises:

ValueError – If the active component of the given functions does not match.

raesl.plot.utils.check_tree_disjunction(nodes: List[ragraph.node.Node])#

Check if list of nodes are not part of each others descendants.

Raises:

ValueError – If node is in the descendants of another node that was provided.

raesl.plot.utils.check_start_and_end_points(start_points: List[Tuple[ragraph.node.Node, List[ragraph.node.Node]]], end_points: List[Tuple[ragraph.node.Node, List[ragraph.node.Node]]])#

Check start and end points for consistency.

Parameters:
  • start_points – List of tuples that contain the component node and list of function nodes that serve as starting points of the function chains.

  • end_points – List of tuples that contain the component node and list of functions nodes that serve as end points of the function chains.

Raises:
  • ValueError – If the component-function pairs do not have a corresponding active component.

  • ValueError – If any of the components are a descendant of another component.

raesl.plot.utils.get_function_tree(graph: ragraph.graph.Graph, node: ragraph.node.Node, levels: int) Tuple[Set[ragraph.node.Node], Set[ragraph.edge.Edge]]#

Walk down the traceability tree of a node.

Parameters:
  • graph – Instantiated ESL graph.

  • node – Node to start the walk from.

  • levels – Number of levels to continue walking.

Returns:

Tuple of the set of all nodes and the set of all edges that describe the traceability tree.

raesl.plot.utils.migrate_edges_between_variables(graph: ragraph.graph.Graph, lead_components: List[ragraph.node.Node]) List[ragraph.edge.Edge]#

Migrate edges between variables up into the decomposition tree.

Parameters:
  • graph – Instantiated ESL graph.

  • lead_components – The components that are displayed.

Returns:

List of edges to are created for the specific view.

Note

The ESL compiler only adds functional dependencies between variables based on the transformation specs of leaf components. As such, when one displays components at higher hierarchical levels gaps appear in the variable dependency structure. Hence, this method is used to fill those gaps by adding additional edges.

raesl.plot.utils.has_mapping_dependency(graph: ragraph.graph.Graph, node: ragraph.node.Node, nodes: List[ragraph.node.Node]) bool#

Check if a node is mapped to any node in a list of nodes.

Parameters:
  • graph – Instantiated ESL graph.

  • node – The node for which the existence of mapping dependencies must be checked.

  • nodes – List of nodes which are to be considered for checking the existence of a mapping dependency.

Returns:

Bool that indicates if a mapping dependency exists.

raesl.plot.utils.filter_nodes(graph: ragraph.graph.Graph, lead_components: List[ragraph.node.Node], node_kinds: List[str]) List[ragraph.node.Node]#

Filter nodes for displaying a multi-domain-matrix.

Parameters:
  • graph – Instantiated ESL graph.

  • lead_components – List of nodes of kind ‘component’ that are leading in filter the other nodes.

  • node_kinds – List of node kinds to be included.

Returns:

List of filtered nodes.

Note

Node of kind ‘component’ are always leading in filtering the nodes to

ensure the consistency within the network of shown dependencies. Since the component hierarchy forms the central structure of an ESL specification.

raesl.plot.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.

Parameters:
  • roots – List of nodes to walk down from.

  • depth – Depth up to which nodes must be returned.

Returns:

Nodes up to the provided list.