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 edge-key support in GenericGraph.__getitem__() #3799

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions manim/mobject/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -679,8 +679,11 @@ def _populate_edge_dict(
"""Helper method for populating the edges of the graph."""
raise NotImplementedError("To be implemented in concrete subclasses")

def __getitem__(self: Graph, v: Hashable) -> Mobject:
return self.vertices[v]
def __getitem__(self: Graph, k: Hashable | tuple[Hashable, Hashable]) -> Mobject:
if isinstance(k, tuple):
return self.edges[k]
else:
return self.vertices[k]
HairlessVillager marked this conversation as resolved.
Show resolved Hide resolved

def _create_vertex(
self,
Expand Down
Loading