Commit 53e686e5 authored by Tiago Peixoto's avatar Tiago Peixoto
Browse files

Improve the performance of Graph.vertex() when filtering is disabled or use_index = False

This fixes issue #197
parent 67e10f3d
......@@ -1360,12 +1360,15 @@ class Graph(object):
``i``-th vertex is returned (which can differ from the vertex with index
``i`` in case of filtered graphs). """
vfilt = self.get_vertex_filter()
if vfilt[0] is None or not use_index:
return libcore.get_vertex(weakref.ref(self), int(i))
if use_index:
v = libcore.get_vertex(weakref.ref(self), int(i))
self.set_vertex_filter(vfilt[0], vfilt[1])
if not v.is_valid():
return v
if vfilt[0] is not None and vfilt[0][v] == vfilt[1]:
return None
return v
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