Last active
July 12, 2016 09:58
-
-
Save Fkawala/afd0a666619c1d2716a5 to your computer and use it in GitHub Desktop.
MWE graph_tool shortest path / distance with multiple targets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import graph_tool as gt | |
from graph_tool.topology import shortest_path, shortest_distance | |
g = gt.Graph() | |
v = list(g.add_vertex(10)) | |
for i in range(9): | |
g.add_edge(i,i+1) | |
# MVE of shortest_path with several targets | |
vlists, elists = shortest_path(g,v[0], v[-3:]) | |
for l in shortest_path(g,v[0], v[-3:]): | |
for org, a in zip(v[-3:], l): | |
print org, ':\t', a, '\n' | |
# MVE of shortest_distance with several targets | |
print shortest_distance(g,v[0], v[-3:]) | |
# shortest_{distance,path} are backward compatible | |
print shortest_distance(g, v[0], v[3]) | |
print shortest_path(g, v[0], v[3]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
the output is as follows: