from manim import *
FONT = "STLiti"
V = [0, 1, 2]
E = [(0, 1), (0, 2), (1, 2)]
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,
                   edge_config={(0, 1): {"color": RED}, (0, 2): {"color": GREEN}, (1, 2): {"color": BLUE}})
        g2 = Graph(V, E, layout="circular", layout_scale=1.0,
                   edge_config={(0, 1): {"stroke_width": 2}, (0, 2): {"stroke_width": 8}, (1, 2): {"stroke_width": 14}})
        g3 = Graph(V, E, layout="circular", layout_scale=1.0,
                   edge_type=DashedLine, edge_config={"dash_length": 0.15})
        g3.clear_updaters()
        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.add(g3)
        self.play(FadeIn(caps[2]), run_time=1.0)
        self.wait(2.6)
