verse.analysis.analysis_tree.AnalysisTree
- class verse.analysis.analysis_tree.AnalysisTree(root: AnalysisTreeNode)
Bases:
object
A tree containing the reachable states the scenario produced.
Methods
collect_leaf_nodes
(node, leafs)contains
(other[, strict, tol])Checks whether this AnalysisTree constains the other AnalysisTree.
dump
(fn)Dumps the AnalysisTree as JSON data to the file "fn".
get_leaf_nodes
(root)height
(root)is_equal
(other)Compares if 2 AnalysisTree's traces are close enough.
leaves
()Return the number of leaves for this tree
load
(fn)Loads the AnalysisTree from the file "fn" as JSON data.
Visualizes the AnalysisTree as a tree graph using networkx.
visualize_dot
(filename[, otype, font])Same as visualize, but rather use graphviz to for visualizing the tree.
- __init__(root: AnalysisTreeNode) None
- contains(other: AnalysisTree, strict: bool = True, tol: float | None = None) bool
Checks whether this AnalysisTree constains the other AnalysisTree. Returns, for reachability, whether the current tree (bloated by a small value) fully contains the other tree or not; for simulation, whether the other tree is close enough to the current tree. strict: requires set of agents to be the same
- dump(fn: str) None
Dumps the AnalysisTree as JSON data to the file “fn”.
- is_equal(other: AnalysisTree) bool
Compares if 2 AnalysisTree’s traces are close enough. For simulation, this simply compares if the point data are within a small range. For reachability, this checks if the start and end points respectively for each dimension are within a small range of the other tree
- leaves() int
Return the number of leaves for this tree
- static load(fn: str) AnalysisTree
Loads the AnalysisTree from the file “fn” as JSON data.
- nodes: List[AnalysisTreeNode]
All nodes in the tree. Order is not guaranteed
- root: AnalysisTreeNode
Root node for the tree
- type: AnalysisTreeNodeType
Type of the analysis tree
- visualize() None
Visualizes the AnalysisTree as a tree graph using networkx. Each node in the graph will correspond to one AnalysisTreeNode, and the edges denote parent/child relationship. Each node will be colored according to a gradient from red to blue using the start_time of each node, where red signifies newer nodes and blue signifies older nodes.
- visualize_dot(filename: str, otype: Literal['png', 'svg', 'pdf', 'jpg'] = 'png', font: str | None = None) None
Same as visualize, but rather use graphviz to for visualizing the tree. filename is the prefix, i.e. doesn’t include extensions. filename.dot will be saved as well as filename.png