gvLayout segfaulting?

I'm trying to use graphviz to plot the state of certain data structures in a C++ project. I'm trying to get a simple example running but some attribute seems to be unintialized. My demo code is:



using namespace std;

int main() {
GVC_t * gvc;
Agraph_t * G;
gvc = gvContext();
G = agopen("test",Agdirected,0);
Agnode_t * n = agnode(G,"root",1);

when I run it I get a segfault at the 'gvLayout(gvc,G,"dot");' line. Any idea what I'm missing? This is graphviz 2.28.0, gcc 4.2.1, Mac OS 10.8.3

In 2.28, the layout

In 2.28, the layout algorithms require the graph library, not the cgraph library. (Starting with 2.30, everything uses cgraph.) If you want to stay 2.28, you'll need to use the old graph API, which is very similar to the cgraph API.

In your case, you just need to change the two lines:

G = agopen("test",AGDIGRAPH);
Agnode_t * n = agnode(G,"root");


and then compile and link with -lgraph

Stack trace

Here's a stack trace for the error:


#0  0x0000000100094413 in agindex ()
#1  0x00000001000943d2 in agget ()
#2  0x0000000100005476 in gvLayoutJobs ()
#3  0x000000010000a6ee in gvLayout ()
#4  0x0000000100000e09 in main () at test.cpp:14


Recent comments