本文整理汇总了Python中scene.GraphScene.generate_treeified_spanning_tree方法的典型用法代码示例。如果您正苦于以下问题:Python GraphScene.generate_treeified_spanning_tree方法的具体用法?Python GraphScene.generate_treeified_spanning_tree怎么用?Python GraphScene.generate_treeified_spanning_tree使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scene.GraphScene
的用法示例。
在下文中一共展示了GraphScene.generate_treeified_spanning_tree方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: construct
# 需要导入模块: from scene import GraphScene [as 别名]
# 或者: from scene.GraphScene import generate_treeified_spanning_tree [as 别名]
def construct(self):
time_per_branch = 0.5
text = TextMobject(
"""
In any tree:
$$E + 1 = V$$
"""
)
gs = GraphScene(SampleGraph())
gs.generate_treeified_spanning_tree()
branches = gs.treeified_spanning_tree.to_edge(LEFT).split()
all_dots = [Dot(branches[0].points[0])]
self.add(text, all_dots[0])
for branch in branches:
self.play(ShowCreation(branch), run_time=time_per_branch)
dot = Dot(branch.points[-1])
self.add(dot)
all_dots.append(dot)
self.dither()
self.remove(*all_dots)
self.play(
FadeOut(text),
FadeIn(Mobject(*gs.edges + gs.vertices)),
*[Transform(*pair) for pair in zip(branches, gs.spanning_tree.split())]
)