[graph-tool] Computation cost of creating a graph

Hang Mang gucko.gucko at googlemail.com
Fri Mar 21 16:49:28 CET 2014

Sorry for asking too much questions today about efficiency but it seems 
today is not my lucky day. I'm trying to build a graph by reading from a 
text file. The graph is 1034 vertices with 53498 edges. Creating this graph 
takes 6 seconds, so I was wondering if it truly takes that time or 
something is inefficient in my way of creating the graph. I have a text 
file that contains the edges in the format: vertex_label_x vertex_label_y. 

What I'm doing basically is maintaining a dictionary that maps from 
vertices labels in the text file to graph-tool vertices indices. When I 
read the file, I check if a label is in the dictionary, if so I retrieve 
its index from the dictionary. Otherwise I create a new vertex and store 
its index by the corresponding label in the dictionary. Then I create the 
edge using the indices of the source and target. I was wondering if my way 
is the wrong way to do that.

This is my code: http://pastie.org/private/n9j7geizaosafmlimujca

Many thanks in advance!

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.skewed.de/pipermail/graph-tool/attachments/20140321/7f0369b3/attachment.htm>

More information about the graph-tool mailing list