-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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 edge-key support in GenericGraph.__getitem__()
#3799
base: main
Are you sure you want to change the base?
Conversation
GenericGraph.__getitem__()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes look good to me. I would appreciate it if you could add some examples to the documentation, so that people know how this works.
Additionally, I left a comment about error messages, so let me know what you think of that :)
Thanks for helping make Manim better!
Co-authored-by: adeshpande <[email protected]>
Great idea! I'll update the documentation later. |
At some point when I wrote the However, given that The current implementation needs to be improved: Vertices can also be tuples, it is not safe to assume that when a tuple is fed to the graph that it will correspond to an edge: verts = [(i, j) for i in range(4) for j in range(4)]
edges = [((0, 0), (0, 1)), ((0, 0), (1, 0)), ((1, 1), (1, 0)), ((1, 1), (0, 1)), ((1, 1), (1, 2)), ((1, 1), (2, 1)), ...]
G = Graph(verts, edges) |
As far as I know, the
Good question! And it's easy to think of plan A that using Plan B is to use
Step 1 and 2 can be swapped for real implementation. It's clean and transparent and I thought it's behavior can be expected. I prefer plan B and I look forward to your suggestions.🤗 |
GenericGraph.__getitem__()
GenericGraph.__getitem__()
I would prefer to let @behackl review this, as I haven't used graphs enough to look at the use cases :) |
Hi @behackl, I'd like to invite you to review my fix. Feel free to comment🥰 |
Motivation and Explanation: Why and how do your changes improve the library?
In the old GenericGraph, you can get the vertex 1 via
g[1]
, but you cannot get the edge 1->2 viag[(1, 2)]
. I think this is a littleconfusing, so I add this support. See #3798.
Links to added or changed documentation pages
https://docs.manim.community/en/stable/reference/manim.mobject.graph.Graph.html#movingvertices: I saw the
g[1]
in this documentation. It's worth to consider add some examples (e.g.g[(1, 2)].animate.set_color(RED)
).Reviewer Checklist