scapy.contrib.automotive.scanner.graph
- class scapy.contrib.automotive.scanner.graph.Graph[源代码]
基类:
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 [源代码]
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] [源代码]
Compute shortest paths from initial to end in graph Partly from https://benalexkeen.com/implementing-djikstras-shortest-path-algorithm-with-python/ # 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 [源代码]
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 [源代码]
Returns a TransitionTuple for an Edge, if available. :param edge: Tuple of EcuStates :return: According TransitionTuple or None
- render(filename: str = 'SystemStateGraph.gv', view: bool = True) None [源代码]
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: