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
d2e8ce3a
Commit
d2e8ce3a
authored
Dec 20, 2010
by
Tiago Peixoto
Browse files
Implement Graph.edge method
parent
9e353964
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/graph_tool/core.py
View file @
d2e8ce3a
...
...
@@ -691,6 +691,26 @@ class Graph(object):
self
.
pop_filter
(
vertex
=
True
)
return
v
def
edge
(
self
,
s
,
t
,
all_edges
=
False
):
"""Return the edge from vertex ``s`` to ``t``, if it exists. If
``all_edges=True`` then a list is returned with all the parallel edges
from ``s`` to ``t``, otherwise only one edge is returned.
This operation will take :math:`O(k(s))` time, where :math:`k(s)` is the
out-degree of vertex :math:`s`.
"""
s
=
self
.
vertex
(
int
(
s
))
t
=
self
.
vertex
(
int
(
t
))
edges
=
[]
for
e
in
s
.
out_edges
():
if
e
.
target
()
==
t
:
if
not
all_edges
:
return
e
edges
.
append
(
e
)
if
all_edges
:
return
edges
return
None
def
edges
(
self
):
"""Return an iterator over the edges."""
return
libcore
.
get_edges
(
weakref
.
ref
(
self
.
__graph
))
...
...
Write
Preview
Supports
Markdown
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