Constants and Styles

This section documents the constants, type definitions, and style configurations available in Manim DSA.

GraphType

GraphType

Type alias for graph representations.

This union type defines all the acceptable formats for representing graphs in Manim DSA:

  • networkx.DiGraph: A NetworkX directed graph object

  • list[list[str]]: Adjacency list with indexes as node names

  • dict[str, list[str]]: Adjacency dictionary with string node names

  • list[list[tuple[str, str | int]]]: Weighted adjacency list with (node, weight) tuples and indexes as node names

  • dict[str, list[tuple[str, str | int]]]: Weighted adjacency dictionary with (node, weight) tuples

Style Classes

MGraphStyle

class MGraphStyle[source]

Bases: object

Style configuration for MGraph visualization.

This class provides predefined style configurations that control the appearance of graph nodes, edges, labels, and other visual elements. Each style variant includes settings for colors, fonts, sizes, and other visual properties.

DEFAULT

A default style configuration for graphs.

Type:

MGraphStyle._DefaultStyle

BLUE

A blue style configuration for graphs.

Type:

MGraphStyle._BlueStyle

PURPLE

A purple style configuration for graphs.

Type:

MGraphStyle._PurpleStyle

GREEN

A green style configuration for graphs.

Type:

MGraphStyle._GreenStyle

class _DefaultStyle

Default style configuration for graphs.

Provides a clean, minimal appearance with white elements on transparent backgrounds. This serves as the base style that other variants can inherit from and modify.

node_circle

Configuration for the appearance of graph nodes, including color, stroke width, and radius.

Type:

dict

edge_line

Configuration for the appearance of graph edges, including color and stroke width.

Type:

dict

edge_tip

Configuration for the appearance of edge tips, including stroke width, fill opacity, and color.

Type:

dict

edge_weight

Configuration for the appearance of edge weight labels, including color, font size, and font.

Type:

dict

start_distance

Distance from edge to the weight label.

Type:

float

class _BlueStyle

Bases: _DefaultStyle

Blue style configuration for graphs.

Inherits from _DefaultStyle and modifies the node circle color and fill color to blue shades, providing a visually distinct appearance for graph nodes.

class _PurpleStyle

Bases: _DefaultStyle

Purple style configuration for graphs.

Inherits from _DefaultStyle and modifies the node circle color and fill color to purple shades, providing a visually distinct appearance for graph nodes.

class _GreenStyle

Bases: _DefaultStyle

Green style configuration for graphs.

Inherits from _DefaultStyle and modifies the node circle color and fill color to green shades, providing a visually distinct appearance for graph nodes.

MTreeStyle

class MTreeStyle[source]

Bases: MGraphStyle

Style configuration for MTree visualization.

This class provides predefined style configurations that control the appearance of tree nodes, edges, labels, and layout properties. Each style variant includes settings for colors, fonts, sizes, spacing, and other visual properties.

DEFAULT

A default style configuration for trees.

Type:

MTreeStyle._DefaultStyle

BLUE

A blue style configuration for trees.

Type:

MTreeStyle._BlueStyle

PURPLE

A purple style configuration for trees.

Type:

MTreeStyle._PurpleStyle

GREEN

A green style configuration for trees.

Type:

MTreeStyle._GreenStyle

class _DefaultStyle

Default style configuration for trees.

Inherits from _DefaultStyle and adds tree-specific layout properties for horizontal and vertical spacing between nodes.

horizontal_gap

The horizontal spacing between sibling nodes in the tree.

Type:

float

vertical_gap

The vertical spacing between parent and child nodes in the tree.

Type:

float

class _BlueStyle

Bases: _DefaultStyle, _BlueStyle

Blue style configuration for trees.

Combines the tree layout properties from _DefaultStyle with the blue color scheme from _BlueStyle.

class _PurpleStyle

Bases: _DefaultStyle, _PurpleStyle

Purple style configuration for trees.

Combines the tree layout properties from _DefaultStyle with the purple color scheme from _PurpleStyle.

class _GreenStyle

Bases: _DefaultStyle, _GreenStyle

Green style configuration for trees. Combines the tree layout properties from _DefaultStyle with the green color scheme from _GreenStyle.

MCollectionStyle

class MCollectionStyle[source]

Bases: object

Style configuration for MCollection visualization.

This class provides predefined style configurations that control the appearance of collection elements including squares, text values, and other visual properties. Each style variant includes settings for colors, fonts, sizes, and other visual properties.

DEFAULT

A default style configuration for collections.

Type:

MCollectionStyle._DefaultStyle

BLUE

A blue style configuration for collections.

Type:

MCollectionStyle._BlueStyle

PURPLE

A purple style configuration for collections.

Type:

MCollectionStyle._PurpleStyle

GREEN

A green style configuration for collections.

Type:

MCollectionStyle._GreenStyle

class _DefaultStyle

Default style configuration for collections.

Provides a clean, minimal appearance with white elements on transparent backgrounds. This serves as the base style that other collection variants can inherit from and modify.

square

Configuration for the appearance of collection element squares, including color, stroke width, and dimensions.

Type:

dict

value

Configuration for the appearance of text values within collection elements, including color, font, and size.

Type:

dict

class _BlueStyle

Bases: _DefaultStyle

Blue style configuration for collections.

Inherits from _DefaultStyle and modifies the square color and fill color to blue shades, providing a visually distinct appearance for collection elements.

class _PurpleStyle

Bases: _DefaultStyle

Purple style configuration for collections.

Inherits from _DefaultStyle and modifies the square color and fill color to purple shades, providing a visually distinct appearance for collection elements.

class _GreenStyle

Bases: _DefaultStyle

Green style configuration for collections.

Inherits from _DefaultStyle and modifies the square color and fill color to green shades, providing a visually distinct appearance for collection elements.

MStackStyle

class MStackStyle[source]

Bases: MCollectionStyle

Style configuration for MStack visualization.

This class provides predefined style configurations that control the appearance of stack elements, containers, and other visual properties. Each style variant includes settings for colors, fonts, sizes, and other visual properties.

DEFAULT

A default style configuration for stacks.

Type:

MStackStyle._DefaultStyle

BLUE

A blue style configuration for stacks.

Type:

MStackStyle._BlueStyle

PURPLE

A purple style configuration for stacks.

Type:

MStackStyle._PurpleStyle

GREEN

A green style configuration for stacks.

Type:

MStackStyle._GreenStyle

class _DefaultStyle

Default style configuration for stacks.

Inherits from _DefaultStyle and adds stack-specific container styling properties.

container

Configuration for the appearance of the stack container, including color.

Type:

dict

class _BlueStyle

Bases: _DefaultStyle, _BlueStyle

Blue style configuration for stacks.

Combines the stack container properties from _DefaultStyle with the blue color scheme from _BlueStyle.

class _PurpleStyle

Bases: _DefaultStyle, _PurpleStyle

Purple style configuration for stacks.

Combines the stack container properties from _DefaultStyle with the purple color scheme from _PurpleStyle.

class _GreenStyle

Bases: _DefaultStyle, _GreenStyle

Green style configuration for stacks.

Combines the stack container properties from _DefaultStyle with the green color scheme from _GreenStyle.

MArrayStyle

class MArrayStyle[source]

Bases: MCollectionStyle

Style configuration for MArray visualization.

This class provides predefined style configurations that control the appearance of array elements, indices, and other visual properties. Each style variant includes settings for colors, fonts, sizes, and other visual properties.

DEFAULT

A default style configuration for arrays.

Type:

MArrayStyle._DefaultStyle

BLUE

A blue style configuration for arrays.

Type:

MArrayStyle._BlueStyle

PURPLE

A purple style configuration for arrays.

Type:

MArrayStyle._PurpleStyle

GREEN

A green style configuration for arrays.

Type:

MArrayStyle._GreenStyle

class _DefaultStyle

Default style configuration for arrays.

Inherits from _DefaultStyle and adds array-specific index styling properties.

index

Configuration for the appearance of array index labels, including color, font, and size.

Type:

dict

class _BlueStyle

Bases: _DefaultStyle, _BlueStyle

Blue style configuration for arrays.

Combines the array index properties from _DefaultStyle with the blue color scheme from _BlueStyle.

class _PurpleStyle

Bases: _DefaultStyle, _PurpleStyle

Purple style configuration for arrays.

Combines the array index properties from _DefaultStyle with the purple color scheme from _PurpleStyle.

class _GreenStyle

Bases: _DefaultStyle, _GreenStyle

Green style configuration for arrays.

Combines the array index properties from _DefaultStyle with the green color scheme from _GreenStyle.

MVariableStyle

class MVariableStyle[source]

Bases: MCollectionStyle

Style configuration for MVariable visualization.

This class provides predefined style configurations that control the appearance of variable elements and their values. Each style variant includes settings for colors, fonts, sizes, and other visual properties.

DEFAULT

A default style configuration for variables.

Type:

MVariableStyle._DefaultStyle

BLUE

A blue style configuration for variables.

Type:

MVariableStyle._BlueStyle

PURPLE

A purple style configuration for variables.

Type:

MVariableStyle._PurpleStyle

GREEN

A green style configuration for variables.

Type:

MVariableStyle._GreenStyle

class _DefaultStyle

Default style configuration for variables.

Inherits from _DefaultStyle and provides the base styling for variable visualization elements.

class _BlueStyle

Bases: _DefaultStyle, _BlueStyle

Blue style configuration for variables. Combines the variable properties from _DefaultStyle with the blue color scheme from _BlueStyle.

class _PurpleStyle

Bases: _DefaultStyle, _PurpleStyle

Purple style configuration for variables. Combines the variable properties from _DefaultStyle with the purple color scheme from _PurpleStyle.

class _GreenStyle

Bases: _DefaultStyle, _GreenStyle

Green style configuration for variables.

Combines the variable properties from _DefaultStyle with the green color scheme from _GreenStyle.