avl._core.visualization module

class avl._core.visualization.Visualization[source]
static add_component(component: Component) None[source]

Adds a component to the visualization tree.

This method inserts the given component into the internal node structure, ensuring that each component is unique within the visualization tree. If the component already exists, a ValueError is raised.

Parameters:

component (object) – The component to be added to the visualization tree.

Raises:

ValueError – If the component already exists in the visualization tree.

static get_node(component: Component | None) AnyNode[source]

Retrieve the node associated with the given component from the AVL visualization.

Parameters:

component (Any) – The component whose node is to be retrieved.

Returns:

The node corresponding to the specified component.

Return type:

Any

Raises:

KeyError – If the component is not found in the nodes dictionary.

static tree(component: Component | None = None) str[source]

Returns a string representation of the AVL visualization tree. This method traverses the AVL visualization tree and constructs a string representation of the tree structure, including the IDs of each node.

Parameters:

component (Any) – The component whose subtree is to be represented.

Returns:

A string representation of the AVL visualization tree.

Return type:

str

static diagram(component: Component | None = None) None[source]

Generates a diagram of the AVL visualization tree using Graphviz. This method creates a directed graph representation of the AVL visualization tree, allowing for visual inspection of the component hierarchy. The diagram is saved as a PNG file.

Parameters:

component (Any) – The component whose subtree is to be represented.