From 3c5e3e1fbee086899c80176e4729ae6d78244f83 Mon Sep 17 00:00:00 2001 From: bibin Date: Fri, 14 Oct 2022 12:53:31 +0200 Subject: [PATCH] initial segmenttree visual: drawing a binary tree --- segment_tree/segment_tree.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 segment_tree/segment_tree.py diff --git a/segment_tree/segment_tree.py b/segment_tree/segment_tree.py new file mode 100644 index 0000000..cae721f --- /dev/null +++ b/segment_tree/segment_tree.py @@ -0,0 +1,13 @@ +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)