ManimCommunity/manim

Add tuple key support in `GenericGraph.__getitem__()`

已关闭

#3,798 创建于 2024年6月9日

 (2 条评论) (0 个反应) (0 位负责人)Python (1,378 个派生)batch import
good first issuenew feature

仓库指标

星标
 (17,820 个星标)
PR 合并指标
 (平均合并 90天 10小时) (30 天内合并 31 个 PR)

描述

Description of proposed feature

vertices = [1, 2, 3, 4]
edges = [(1, 2), (2, 3), (3, 4), (1, 3), (1, 4)]
g = Graph(vertices, edges)
assert isinstance(g[1], Dot)  # This is OK
assert isinstance(g[(1, 2)], Line)  # But this will raise a KeyError

imo This is confusing. Why not add a support for edge mapping?

How can the new feature be used?

Every time people want to get or set a edge, just write g[(1, 2)] instead of g.edges[(1, 2)].

贡献者指南