我正在尝试使用 Graphviz 的 cgraph 库 api 创建从节点 a 到 b 的 2 条边,但是第二次调用agedge 总是返回 NULL。我在下面的代码中做错了吗?Graphviz 版本是 2.34。谢谢。
#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;
}