Efficiently iterating over vertex pairs in graph-tool

Hello all,

I am working on the generation of some random graph model in which
probability of having an edge between two given vertices is some
complicated function. Hence I cannot use in-built models to generate this
graph. Thus, I am using nested for loops to generate it. However, this
makes the code extremely slow. Is it possible to iterate over all the pairs
of vertices efficiently in graph-tool so that there would be sufficient
increase in the speed?

Thank you

attachment.html (759 Bytes)

There is no magic bullet. If you have to iterate using Python, it will be slow.

I will be writing some documentation explaining how to write C++ extensions
for graph-tool.

In the mean time, depending on your algorithm, you may be able to increase
speed by representing your graph as a sparse matrix (using adjacency()). You
may also try numba, but it will not speedup the interaction with graph-tool.


Thanks Tiago for a quick reply. I think I will write the generation part in
C++/Fortran and save the graph-data, say in the form of an edge list, in a
file which can then be processed using graph-tool. However, I really
appreciate your idea of writing a documentation for explaining the writings
of extensions for graph-tool.

On a side note, since your generalized communities model also needs
different probability value for each pair, I would guess that for
generation of such graphs, you have written a code in C++ and that has not
been included in graph-tool. Is there a plan to include the same in the
graph-tool sometime in near future?


attachment.html (2.79 KB)

I have code for the model inference --- which is different from network
generation. But I do plan to include it in the library, when time permits.