graphviz_draw() cannot plot loops anymore


I get a segmentation fault when trying to plot a loop with
graphviz_draw(). Here is a minimal example to reproduce the error:

import graph_tool.all as gt
g = gt.Graph()
v0 = g.add_vertex()
v1 = g.add_vertex()
e01 = g.add_edge(v0,v1)
e11 = g.add_edge(v1,v1) # loop

I have version 2.33 of python3-graph-tool installed on my computer which
runs on Linux Mint 19.2 Tina (based on Ubuntu 18.04 LTS, bionic). My
graphviz version is 2.40.1-2.

It works fine if I don't add the loop e11 to the graph.

It works fine if I use gt.graph_draw() instead of gt.graphviz_draw()

It works fine if I use graphviz directly (via a .dot file).

It did work fine in earlier versions of graph_tool.

Can anyone reproduce this?

Best regards

I can reproduce this.

attachment.html (2.46 KB)

I can also reproduce this, but this code has not been changed in several

I consider graphviz_draw() to be largely deprecated (in favor of
graph_draw()), since the graphviz interface is fairly buggy and

I'm planning to remove this function altogether in new releases, and I'm
not very inclined to debug it.


I tracked this down and I believe the issue is related to the
interpretation of the global variables Agdirected and Agundirected from
libgvc. If you replace lines 75 and 76 of from:

        libgv_directed = libgv.Agdirected libgv_undirected =


        libgv_directed = ctypes.c_int.in_dll(libgv, "Agdirected")
        libgv_undirected = ctypes.c_int.in_dll(libgv, "Agundirected")

these values are interpreted correctly (as bit fields, not function
pointers) and the test case works again.


attachment.html (5.96 KB)

Thanks for the fix, and the patch in gitlab, which has been merged.


Jeff: Thanks very much for finding and fixing the bug! Plotting loops
works fine for me now.

Tiago: I can understand very well that it is a lot of work to maintain
the two similar functions graphviz_draw() and graph_draw() at the same
time. Still, it would be a pity if graphviz_draw() disappears completely
in future versions of graph-tool. I'm using graphviz_draw() a lot
because it has some features that graph_draw() doesn't have. In
particular, graphviz can put text nicely into oval-shaped vertices.
Cairo, however, produces large circles that hide much of the graph.
Using the vertex property "aspect" is very slow and does not improve the
plots much. Examples are available here:

Best regards

Indeed, we still need some form of non-overlapping heuristics in

I'll leave graphviz_draw() for the time being.


I'll leave graphviz_draw() for the time being.

Thanks, Tiago!

Best regards