Commit d5ab42b6 authored by Tiago Peixoto's avatar Tiago Peixoto
Browse files

Fix behaviour of new vertices or edges in filtered graphs

Newly added vertices or edges in filtered graphs now automatically
appear in them.
parent 49f2ec3b
......@@ -961,8 +961,13 @@ class Graph(object):
"""Add a vertex to the graph, and return it. If ``n > 1``, ``n``
vertices are inserted and a list is returned."""
vlist = [libcore.add_vertex(weakref.ref(self.__graph)) \
for i in xrange(0, n)]
vlist = []
vfilt = self.get_vertex_filter()
for i in xrange(n):
v = libcore.add_vertex(weakref.ref(self.__graph))
if vfilt[0] is not None:
vfilt[0][v] = not vfilt[1]
if n == 1:
return vlist[0]
return vlist
......@@ -998,7 +1003,11 @@ class Graph(object):
"""Add a new edge from ``source`` to ``target`` to the graph, and return
return libcore.add_edge(weakref.ref(self.__graph), source, target)
e = libcore.add_edge(weakref.ref(self.__graph), source, target)
efilt = self.get_edge_filter()
if efilt[0] is not None:
efilt[0][e] = not efilt[1]
return e
def remove_edge(self, edge):
"""Remove an edge from the graph."""
Supports Markdown
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