from manim import *
FONT = "STLiti"
V = [1, 2, 3, 4, 5, 6]
E = [(1, 2), (2, 3), (3, 4), (4, 5), (5, 6), (6, 1), (5, 1), (1, 3), (3, 5)]
NAMES = ["spring", "circular", "kamada_kawai", "planar", "random", "shell", "spectral", "spiral"]
class GraphExample(Scene):
    def construct(self):
        head = VGroup(Text("Graph ", font="Consolas", font_size=32, color=YELLOW),
                      Text("内置的八种布局", font=FONT, font_size=32, color=YELLOW)).arrange(RIGHT, buff=0.1).to_edge(UP)
        cards = []
        for n in NAMES:
            g = Graph(V, E, layout=n, layout_scale=0.75)
            cap = Text(n, font="Consolas", font_size=20, color=GREEN).next_to(g, DOWN, buff=0.12)
            cards.append(VGroup(g, cap))
        Group(*cards).arrange_in_grid(rows=2, cols=4, buff=(0.9, 1.0)).scale(1.2)
        self.add(head)
        for c in cards:
            self.play(FadeIn(c[0]), FadeIn(c[1]), run_time=0.45)
        self.wait(2.0)
