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
de13d051
Commit
de13d051
authored
Jul 16, 2017
by
Tiago Peixoto
Browse files
shortest_distance(): Return distance array for list of targets
parent
263a4f74
Pipeline
#342
passed with stage
in 167 minutes and 29 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/graph_tool/topology/__init__.py
View file @
de13d051
...
...
@@ -1568,9 +1568,12 @@ def shortest_distance(g, source=None, target=None, weights=None,
Returns
-------
dist_map : :class:`~graph_tool.PropertyMap`
Vertex property map with the distances from source. If source is ``None``,
it will have a vector value type, with the distances to every vertex.
dist_map : :class:`~graph_tool.PropertyMap` or :class:`numpy.ndarray`
Vertex property map with the distances from source. If ``source`` is
``None``, it will have a vector value type, with the distances to every
vertex. If ``source`` is an iterable, this will be of type
:class:`numpy.ndarray`, and contain only the distances to those specific
targets.
pred_map : :class:`~graph_tool.PropertyMap` (optional, if ``pred_map == True``)
Vertex property map with the predecessors in the search tree.
pred_map : :class:`numpy.ndarray` (optional, if ``return_reached == True``)
...
...
@@ -1667,7 +1670,9 @@ def shortest_distance(g, source=None, target=None, weights=None,
"""
tgtlist
=
False
if
isinstance
(
target
,
collections
.
Iterable
):
tgtlist
=
True
target
=
numpy
.
asarray
(
target
,
dtype
=
"int64"
)
elif
target
is
None
:
target
=
numpy
.
array
([],
dtype
=
"int64"
)
...
...
@@ -1725,7 +1730,7 @@ def shortest_distance(g, source=None, target=None, weights=None,
_prop
(
"e"
,
u
,
weights
),
dense
)
if
source
is
not
None
and
len
(
target
)
>
0
:
if
len
(
target
)
==
1
:
if
len
(
target
)
==
1
and
not
tgtlist
:
dist_map
=
dist_map
.
a
[
target
[
0
]]
else
:
dist_map
=
numpy
.
array
(
dist_map
.
a
[
target
])
...
...
Tiago Peixoto
@count0
mentioned in issue
#406 (closed)
·
Jul 16, 2017
mentioned in issue
#406 (closed)
mentioned in issue #406
Toggle commit list
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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