Skip to content

Commit 91d324f

Browse files
committed
✨ add graph.remove_all()
1 parent ff02d99 commit 91d324f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

pynode_next/graph.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,15 @@ def add_all(self, elements: Iterable[Union[Node, Edge]]):
147147
elif isinstance(i, Edge):
148148
self.add_edge(i)
149149
pause(20)
150+
151+
def remove_all(self, elements: Iterable[Union[Node, Edge]]):
152+
"""Removes all node and edge objects from an iterable. all elements need to be of the type `Node` or `Edge`"""
153+
for i in elements:
154+
if isinstance(i, Node):
155+
self.remove_node(i)
156+
elif isinstance(i, Edge):
157+
self.remove_edge(i)
158+
pause(20)
150159

151160
def has_edge(self, edge):
152161
"""Checks if an edge exists in the graph."""

0 commit comments

Comments
 (0)