Hi and happy new year graph coders! 

The shortest_distance function implements the Floyd's algorithm. I am
carefully following the example provided by the  docs
<https://graph-tool.skewed.de/static/doc/topology.html#graph_tool.topology.shortest_distance>
   
but the function doesn't return the expected result. 


Here is my trivial try:

 
# -------------------
import graph_tool as gt 
from graph_tool.topology import shortest_distance
import numpy as np 

wedges=[(2, 0, 6.0), (0, 3, 7.0), (0, 2, 2.0)]
print(wedges)

# Définition of the weighted graph
g= gt.Graph(directed=True) 
weight = g.new_edge_property("double") 
g.add_edge_list(np.array(wedges), eprops=[weight]) 

# Floyd call
dist=shortest_distance(g, dense=True) 

# I'm expecting the vector distance from vertex 2
print(dist[g.vertex(2)])

 # -------------------
 
 outputting :
 
 # -------------------
 [(2, 0, 6.0), (0, 3, 7.0), (0, 2, 2.0)]
array([         1, 2147483647,          0,          2], dtype=int32)
# -------------------


This not the correct distance vector from the 2-indexed node nor the correct
predecessor vector. And I don't understand why I get an int32 vector since
the weights have double type.


Can somebody please correct my code in order to get the correct distances? 

Pascal
 
 



--
Sent from: 
http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/
_______________________________________________
graph-tool mailing list
graph-tool@skewed.de
https://lists.skewed.de/mailman/listinfo/graph-tool

Reply via email to