Commit b69fdece authored by Tiago Peixoto's avatar Tiago Peixoto

Remove 'remove_vertex_if()' and 'remove_edge_if()'

These are redundant functions which can be trivially implemented as
loops.
parent a8481771
......@@ -36,14 +36,12 @@
.. automethod:: add_vertex
.. automethod:: remove_vertex
.. automethod:: remove_vertex_if
The following functions allow for addition and removal of
edges in the graph.
.. automethod:: add_edge
.. automethod:: remove_edge
.. automethod:: remove_edge_if
The following functions allow for easy removal of vertices of
edges from the graph.
......
......@@ -1191,15 +1191,6 @@ class Graph(object):
libcore.remove_vertex(self.__graph, vertex, fast)
def remove_vertex_if(self, predicate):
"""Remove all the vertices from the graph for which ``predicate(v)``
evaluates to ``True``. """
N = self.num_vertices()
for i in range(0, N):
v = self.vertex(N - i - 1)
if predicate(v):
self.remove_vertex(v)
def clear_vertex(self, vertex):
"""Remove all in and out-edges from the given vertex."""
del_es = set()
......@@ -1224,17 +1215,6 @@ class Graph(object):
self.__check_perms("del_edge")
return libcore.remove_edge(self.__graph, edge)
def remove_edge_if(self, predicate):
"""Remove all edges from the graph, for which ``predicate(e)`` evaluates
to ``True``."""
for v in self.vertices():
del_es = []
for e in v.out_edges():
if predicate(e):
del_es.append(e)
for e in del_es:
self.remove_edge(e)
def clear(self):
"""Remove all vertices and edges from the graph."""
self.__check_perms("del_vertex")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment