Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tuple key support in GenericGraph.__getitem__() #3798

Open
HairlessVillager opened this issue Jun 9, 2024 · 0 comments
Open

Add tuple key support in GenericGraph.__getitem__() #3798

HairlessVillager opened this issue Jun 9, 2024 · 0 comments
Labels
new feature Enhancement specifically adding a new feature (feature request should be used for issues instead)

Comments

@HairlessVillager
Copy link
Contributor

HairlessVillager commented Jun 9, 2024

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)].

@HairlessVillager HairlessVillager added the new feature Enhancement specifically adding a new feature (feature request should be used for issues instead) label Jun 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature Enhancement specifically adding a new feature (feature request should be used for issues instead)
Projects
Status: 🆕 New
Development

No branches or pull requests

1 participant