user2248525
user2248525

Reputation: 51

graph tool edge text not working

I am trying to create an interactive finite state automata in python using graph-tool, but I can't get edge labels to work.

Here is the python file:

from graph_tool.all import *

g = Graph()
edge_labels = g.new_edge_property("string")
a = g.add_vertex()
b = g.add_vertex()
e = g.add_edge(a, b)
edge_labels[e] = 'a'
props = {'text': edge_labels}
graph_draw(
    g,
    eprops=props,
    output_size=(200, 200),
)

This the crash:

*** Error in `/usr/lib/python-exec/python2.7/python2': free(): invalid size: 0x00000000023d0840 ***
======= Backtrace: =========
/lib64/libc.so.6(+0x77a4b)[0x7f73bac77a4b]
/lib64/libc.so.6(+0x7f6be)[0x7f73bac7f6be]
/lib64/libc.so.6(+0x7ffa6)[0x7f73bac7ffa6]
/usr/lib64/python2.7/site-packages/graph_tool/draw/libgraph_tool_draw.so(+0xbba31)[0x7f73970d5a31]
/usr/lib64/python2.7/site-packages/graph_tool/topology/libgraph_tool_topology.so(_ZN5boost11coroutines26detail14pull_coroutineINS_6python3api6objectEE13control_block7destroyEPS7_+0x87)[0x7f73a281daf7]
/usr/lib64/python2.7/site-packages/graph_tool/draw/libgraph_tool_draw.so(_Z10cairo_drawRN10graph_tool14GraphInterfaceEN5boost3anyES3_S3_bNS2_6python4dictES5_S5_S5_dlNS4_3api6objectE+0x548)[0x7f73970d8168]
/usr/lib64/python2.7/site-packages/graph_tool/draw/libgraph_tool_draw.so(+0x251666)[0x7f739726b666]
/usr/lib64/python2.7/site-packages/graph_tool/draw/libgraph_tool_draw.so(+0x251ba8)[0x7f739726bba8]
/usr/lib64/libboost_python-2.7.so.1.65.0(_ZNK5boost6python7objects8function4callEP7_objectS4_+0x2d7)[0x7f73a8aedd67]
/usr/lib64/libboost_python-2.7.so.1.65.0(+0x25f48)[0x7f73a8aedf48]
/usr/lib64/libboost_python-2.7.so.1.65.0(_ZNK5boost6python6detail17exception_handlerclERKNS_9function0IvEE+0x6b)[0x7f73a8af4beb]
/usr/lib64/python2.7/site-packages/graph_tool/libgraph_tool_core.so(+0xa17cb3)[0x7f73a9982cb3]
/usr/lib64/libboost_python-2.7.so.1.65.0(_ZNK5boost6python6detail17exception_handlerclERKNS_9function0IvEE+0x3a)[0x7f73a8af4bba]
/usr/lib64/python2.7/site-packages/graph_tool/libgraph_tool_core.so(+0xa17bd3)[0x7f73a9982bd3]
/usr/lib64/libboost_python-2.7.so.1.65.0(_ZNK5boost6python6detail17exception_handlerclERKNS_9function0IvEE+0x3a)[0x7f73a8af4bba]
/usr/lib64/python2.7/site-packages/graph_tool/libgraph_tool_core.so(+0xa17b73)[0x7f73a9982b73]
/usr/lib64/libboost_python-2.7.so.1.65.0(_ZN5boost6python21handle_exception_implENS_9function0IvEE+0x3f)[0x7f73a8af498f]
/usr/lib64/libboost_python-2.7.so.1.65.0(+0x23059)[0x7f73a8aeb059]
/usr/lib64/libpython2.7.so.1.0(PyObject_Call+0x43)[0x7f73bb21cf73]
/usr/lib64/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x5595)[0x7f73bb2b6275]
...
/lib64/libc.so.6(__libc_start_main+0xf1)[0x7f73bac20521]
/usr/lib/python-exec/python2.7/python2(_start+0x2a)[0x40064a]
======= Memory map: ========
00400000-00401000 r-xp 00000000 08:03 28461541                           /usr/bin/python2.7
00600000-00601000 r--p 00000000 08:03 28461541                           /usr/bin/python2.7
00601000-00602000 rw-p 00001000 08:03 28461541                           /usr/bin/python2.7
00aa9000-027cb000 rw-p 00000000 00:00 0                                  [heap]
7f737c000000-7f737c022000 rw-p 00000000 00:00 0 
7f737c022000-7f7380000000 ---p 00000000 00:00 0 
7f7380000000-7f7380021000 rw-p 00000000 00:00 0 
7f7380021000-7f7384000000 ---p 00000000 00:00 0 
7f7384000000-7f7384021000 rw-p 00000000 00:00 0 
7f7384021000-7f7388000000 ---p 00000000 00:00 0 
7f738a3be000-7f738a477000 r--p 00000000 08:03 24020070                   /usr/share/fonts/dejavu/DejaVuSans.ttf
7f738a477000-7f738a482000 r--s 00000000 08:03 19015130                   /var/cache/fontconfig/acc285bc1956c3c4bc7afb41d537a85a-le64.cache-7
...

I have no idea where to start looking for the issue. Running with python 3 gives a similar error. If I remove the edge labels, it works.

If not a solution to this problem, are there any libraries that can be suggested as alternatives to graph-tool? I want the the visualisation to be interactive, since I eventually want the FSA to be modifiable in the GUI.

Upvotes: 1

Views: 407

Answers (1)

Tiago Peixoto
Tiago Peixoto

Reputation: 5261

This is a cairo/pango bug.

You can get around it by specifying the font family explicitly:

graph_draw(g, eprops=props, edge_font_family="Times")

EDIT: In fact, this turned out to be subtle bug when using cairo together with boost::coroutines. This has been fixed now in version 2.25, and the original example should work without modification.

Upvotes: 1

Related Questions