class scapy.contrib.automotive.scanner.graph.Graph[source]

Bases: object

Helper object to store a directional Graph of EcuState objects. An edge in this Graph is defined as Tuple of two EcuStates. A node is defined as EcuState.

self.edges is a dict of all possible next nodes e.g. {‘X’: [‘A’, ‘B’, ‘C’, ‘E’], …}

self.__transition_functions has all the transition_functions between two nodes, with the two nodes as a tuple as the key e.g. {(‘X’, ‘A’): 7, (‘X’, ‘B’): 2, …}

add_edge(edge: _Edge, transition_function: '_TransitionTuple' | None = None) None[source]

Inserts new edge in directional graph :param edge: edge from node to node :param transition_function: tuple with enter and cleanup function

static dijkstra(graph: Graph, initial: EcuState, end: EcuState) List[EcuState][source]

Compute shortest paths from initial to end in graph Partly from # noqa: E501 :param graph: Graph where path is computed :param initial: Start node :param end: End node :return: A path as list of nodes

downrate_edge(edge: Tuple[EcuState, EcuState]) None[source]

Increases the weight of an Edge :param edge: Edge on which the weight has t obe increased

get_transition_tuple_for_edge(edge: _Edge) '_TransitionTuple' | None[source]

Returns a TransitionTuple for an Edge, if available. :param edge: Tuple of EcuStates :return: According TransitionTuple or None

property nodes: List[EcuState] | Set[EcuState]

Get a set of all nodes in this Graph :return:

render(filename: str = 'SystemStateGraph.gv', view: bool = True) None[source]

Renders this Graph as PDF, if graphviz is installed.

  • filename – A filename for the rendered PDF.

  • view – If True, rendered file will be opened.

property transition_functions: Dict[_Edge, '_TransitionTuple' | None]

Get the dict of all TransistionTuples :return: