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?


On Tue, Jan 24, 2017 at 3:37 PM, Tiago de Paula Peixoto <> wrote:
On 24.01.2017 08:59, Snehal Shekatkar wrote:
> 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?

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.


Tiago de Paula Peixoto <>

graph-tool mailing list


Snehal Madhukar Shekatkar