soi-manim/segment_tree/segment_tree.py

14 lines
375 B
Python
Raw Normal View History

from manim import *
import networkx as nx
class Tree(Scene):
def construct(self):
vertices = list(range(1, 25))
edges = []
for v in vertices[1:]:
edges.append((v // 2, v))
self.play(Create(Graph(vertices, edges, labels=True, layout="tree", layout_config={"vertex_spacing": (1.0, 1.0)}, root_vertex=1)))
self.wait(2)