:py:mod:`raesl.plot.utils` ========================== .. py:module:: raesl.plot.utils .. autoapi-nested-parse:: RaESL plotting utility functions. Module Contents --------------- Functions ~~~~~~~~~ .. autoapisummary:: raesl.plot.utils.get_component_function_dicts raesl.plot.utils.crawl_descendants raesl.plot.utils.get_neighbors raesl.plot.utils.get_paths_between_all raesl.plot.utils.get_paths raesl.plot.utils.select_components_for_function_path raesl.plot.utils.add_level raesl.plot.utils.rebuild_hierarchical_structure raesl.plot.utils.get_all_descendants raesl.plot.utils.check_comp_func_pairs raesl.plot.utils.check_tree_disjunction raesl.plot.utils.check_start_and_end_points raesl.plot.utils.get_function_tree raesl.plot.utils.migrate_edges_between_variables raesl.plot.utils.has_mapping_dependency raesl.plot.utils.filter_nodes raesl.plot.utils.get_up_to_depth .. py:function:: 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. .. py:function:: 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. :param node: The parent node to unfold. :param 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" :obj:`Edge` objects in the preprocessing step using :obj:`ragraph.graph.GraphView` objects. .. py:function:: 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. :param graph: Instantiated ESL graph. :param root: The root node for which the nodes must be sought up to the given degree. :param node: The node for which the direct neighbors must be collected. :param node_kinds: The kinds of the neighbor nodes that must be collected. :param degree: The degree up to which neighbors must be collected (neighbors of :param neighbors). Defaults to 1.: Returns Set of neighbors. .. py:function:: 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. :param sources: List of starting nodes of paths. :param targets: Set of ending nodes of path. :param edges: List of edges between nodes. :Yields: List of lists of node names. .. py:function:: 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. :param source: The source node where all paths should start. :param edges: Dictionary of Node to Node to Edge. Contains the edges to be considered when searching for paths. :param targets: Set of node where the paths should end. :param visited: List of nodes already visited. Required to prevent running in cycles. :returns: List of lists of node names. .. py:function:: 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. :param graph: Instantiated ESL graph. :param 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. :param end_points: List of Tuples that contain the component node and list of functions that nodes server. :param levels: Number of levels to decompose intermediate components into. This number is relative to the maximum of the depth of the start :param node and end node.: .. note:: Components that are a descendant of the start or end component node of the function path are excluded. .. py:function:: 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. :param graph: Instantiated ESL graph. :param sliced: Sliced data graph. .. note:: Creates deepcopies of child nodes to preserve the original data structure. .. py:function:: rebuild_hierarchical_structure(graph: ragraph.graph.Graph, sliced: ragraph.graph.Graph) Rebuilding the hierarchical structure within the sliced graph. :param graph: Instantiated ESL graph. :param sliced: Sliced data graph. .. note:: Creates deepcopies of child nodes to preserve the original data structure. .. py:function:: get_all_descendants(nodes: List[ragraph.node.Node]) -> Set[ragraph.node.Node] Get all descendants from a list of provided nodes. :param nodes: List of nodes for which the descendants must be found. :returns: Set of nodes containing all descendants of the provided nodes. .. py:function:: 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. :param points: List of points for which the consistency must be checked. :raises ValueError: If the active component of the given functions does not match. .. py:function:: 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. .. py:function:: 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. :param start_points: List of tuples that contain the component node and list of function nodes that serve as starting points of the function chains. :param 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. :raises ValueError: If any of the components are a descendant of another component. .. py:function:: 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. :param graph: Instantiated ESL graph. :param node: Node to start the walk from. :param 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. .. py:function:: 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. :param graph: Instantiated ESL graph. :param 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. .. py:function:: 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. :param graph: Instantiated ESL graph. :param node: The node for which the existence of mapping dependencies must be checked. :param 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. .. py:function:: 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. :param graph: Instantiated ESL graph. :param lead_components: List of nodes of kind 'component' that are leading in filter the other nodes. :param 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. .. py:function:: 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. :param roots: List of nodes to walk down from. :param depth: Depth up to which nodes must be returned. :returns: Nodes up to the provided list.