Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Tiago Peixoto
graph-tool
Commits
53e686e5
Commit
53e686e5
authored
Dec 19, 2014
by
Tiago Peixoto
Browse files
Improve the performance of Graph.vertex() when filtering is disabled or use_index = False
This fixes issue #197
parent
67e10f3d
Changes
1
Show whitespace changes
Inline
Side-by-side
src/graph_tool/__init__.py
View file @
53e686e5
...
@@ -1360,12 +1360,15 @@ class Graph(object):
...
@@ -1360,12 +1360,15 @@ class Graph(object):
``i``-th vertex is returned (which can differ from the vertex with index
``i``-th vertex is returned (which can differ from the vertex with index
``i`` in case of filtered graphs). """
``i`` in case of filtered graphs). """
vfilt
=
self
.
get_vertex_filter
()
vfilt
=
self
.
get_vertex_filter
()
if
vfilt
[
0
]
is
None
or
not
use_index
:
return
libcore
.
get_vertex
(
weakref
.
ref
(
self
),
int
(
i
))
try
:
try
:
if
use_index
:
self
.
set_vertex_filter
(
None
)
self
.
set_vertex_filter
(
None
)
v
=
libcore
.
get_vertex
(
weakref
.
ref
(
self
),
int
(
i
))
v
=
libcore
.
get_vertex
(
weakref
.
ref
(
self
),
int
(
i
))
finally
:
finally
:
self
.
set_vertex_filter
(
vfilt
[
0
],
vfilt
[
1
])
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
]:
if
vfilt
[
0
]
is
not
None
and
vfilt
[
0
][
v
]
==
vfilt
[
1
]:
return
None
return
None
return
v
return
v
...
...
Tiago Peixoto
@count0
mentioned in issue
#197 (closed)
·
Dec 19, 2014
mentioned in issue
#197 (closed)
mentioned in issue #197
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment