I am currently implementing an existing networkx implementation in graph-tool
and observed that the new implementation runs slower than the networkx one.
I then found out that a simple node access is already slower. So I have the
exact same undirected graph with 1000 nodes and avg. degree of 2 in nx and
gt, and then run:

def select(g):
    for i in range(1000):
        n = g.vertex(0)

def select_nx(g):
    for i in range(1000):
        n = g.nodes(0)

%time select(gt)
CPU times: user 75.6 ms, sys: 69 µs, total: 75.6 ms
Wall time: 72.6 ms

%time select_nx(g)
CPU times: user 3.82 ms, sys: 0 ns, total: 3.82 ms
Wall time: 3.46 ms

So I am wondering whether this is to be expected and that I can only see the
drastic runtime improvements when working with calculations like shortest
paths etc.



--
View this message in context: 
http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/Simple-node-access-runtime-tp4026645.html
Sent from the Main discussion list for the graph-tool project mailing list 
archive at Nabble.com.
_______________________________________________
graph-tool mailing list
[email protected]
https://lists.skewed.de/mailman/listinfo/graph-tool

Reply via email to