Thanks for your answer, now, i get the correct distances, nice!

I was benchmarking some Floyd APSP source-code. 

Some results (in seconds) on a random graph with 800 nodes and abouts 10000
edges:

Networkx             : 82.66
Python with array    : 38.97
Numpy from Networkx  : 1.67 (no predecessors calculation)
graph-tool           : 0.91
Scipy (Cython)       : 0.50 
Pure C code          : 0.35


Below the code I used for Graph-tool test:

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

def random_edges(n, density, max_weight=100):
    M=n*(n-1)//2
    m=int(density*M)
    edges=set()
    wedges=[]
    while len(edges)<m:
        L=(randrange(n),randrange(n))
        if L[0]!=L[1] and L not in edges:
            w=float(randrange(max_weight))
            wedges.append(L+(w,))
            edges.add(L)
    return wedges

n=800
density=0.33

wedges=random_edges(n, density)

start=clock()

g= gt.Graph(directed=True) 
weight = g.new_edge_property("double") 
g.add_edge_list(np.array(wedges), eprops=[weight]) 
dist = shortest_distance(g, weights=weight, dense=True)

end=clock()
print("graph-tool  \t: %.2f" %(end-start))
# -------------------






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

Reply via email to