from manim import *
FONT = "STLiti"
V = [0, 1, 2]
E = [(0, 1), (0, 2), (1, 2)]
LAB = {i: Text(str(i), font=FONT, font_size=28, color=BLACK) for i in V}
class GraphExample(Scene):
    def construct(self):
        head = Text("顶点的配置：颜色 / 标签 / 星形", font=FONT, font_size=32, color=YELLOW).to_edge(UP)
        g1 = Graph(V, E, layout="circular", layout_scale=1.0,
                   vertex_config={0: {"color": RED}, 1: {"color": GREEN}, 2: {"color": BLUE}})
        g2 = Graph(V, E, layout="circular", layout_scale=1.0,
                   labels=LAB, vertex_config={"color": WHITE, "radius": 0.28})
        g3 = Graph(V, E, layout="circular", layout_scale=1.0,
                   vertex_type=Star, vertex_config={"outer_radius": 0.22, "color": YELLOW})
        row = Group(g1, g2, g3).arrange(RIGHT, buff=1.8).scale(1.25)
        caps = Group(*[Text(s, font=FONT, font_size=24, color=YELLOW_C) for s in
                       ("不同颜色的顶点", "带标签的顶点", "星形的顶点")])
        for i, cap in enumerate(caps):
            cap.next_to(row[i], DOWN, buff=0.45)
        self.add(head)
        self.play(FadeIn(g1), FadeIn(caps[0]), run_time=1.0)
        self.play(FadeIn(g2), FadeIn(caps[1]), run_time=1.0)
        self.play(FadeIn(g3), FadeIn(caps[2]), run_time=1.0)
        self.wait(2.6)
