MTree

Qualified name: manim\_dsa.m\_graph.m\_tree.MTree

class MTree(tree, root=None, style=<manim_dsa.constants.MTreeStyle._DefaultStyle object>)[source]

Bases: MGraph

Manim Tree: a class for visualizing the tree data structure using the Manim animation engine.

Parameters:
  • tree (GraphType) – The tree representation, which can be weighted or unweighted. Can be: - list[list[str]] or dict[str, list[str]] for unweighted tree - list[list[tuple[str, str | int]]] or dict[str, list[tuple[str, str | int]]] for weighted tree

  • root (str | None, optional) – The root node of the tree. If None, topological sorting is used to determine the root.

  • style (MTreeStyle._DefaultStyle, optional) – The style configuration to be applied to the tree. Defaults to MTreeStyle.DEFAULT.

Methods

node_layout

Applies a hierarchical layout to the nodes of the tree.

Inherited Attributes

animate

Used to animate the application of any method of self.

color

depth

The depth of the mobject.

fill_color

If there are multiple colors (for gradient) this returns the first one

height

The height of the mobject.

n_points_per_curve

sheen_factor

stroke_color

width

The width of the mobject.

node_layout()[source]

Applies a hierarchical layout to the nodes of the tree.

Returns:

The updated instance of the MTree with nodes arranged according to the hierarchical layout.

Return type:

self