How to create multiple edges between two nodes using the library api?

Hi, I'm trying to create 2 edges from a to b using cgraph library api, but unfortunately the second call to agedge always return 0. Do I do something wrong in the code shown below? Thanks.

#include "gvc.h"
#include "cgraph.h"
#include <iostream>
using namespace std;

int main()
{
    GVC_t *context = gvContext();
    Agraph_t *graph = agopen((char *)("graph"), Agdirected, NULL);
    agsafeset(graph, (char *)("rankdir"), (char *)("LR"), (char *)(""));

    Agnode_t *a = agnode(graph, (char *)("a"), 1);
    Agnode_t *b = agnode(graph, (char *)("b"), 1);
    Agedge_t *e_ab0 = agedge(graph, a, b, (char *)("e_ab0"), 1);
    Agedge_t *e_ab1 = agedge(graph, a, b, (char *)("e_ab1"), 1);

    //e_ab1 is always 0
    cout << e_ab0 << endl << e_ab1 << endl;

    //other code...
    return 0;
}

What system are you running

What system are you running this on? If Visual Studio on Windows, check the value of Agdirected.strict. If this is 1, then the graph being created is strict, so it won't let you create another edge. Basically, the system is picking up a bogus value for Agdirected. At present, we don't know how to fix this. As a workaround, try replacing Agdirected with a local variable dir:

Agdesc_t dir = { 1, 0, 0, 1 };

It works now

I use mingw gcc 4.8 on Windows and Agdirected.strict is 1. It can create more than one edge now following your method. Thanks.

Btw, could the moderator delete the repeated post http://graphviz.org/content/how-create-multiple-edges-between-two-nodes-using-cgraph-library-api

Recent comments