我正在玩CFG,有一次我有一个有优势的图。IE这是一个做同时循环。
loop:
...
ifeq ... goto loop;
为什么,如果我将相同的Agnode_t
指针传递给agedge()
作为头和尾,函数会失败并返回nullptr
?
示例代码:
Agnode_t* n = ...;
Agedge_t* e = agedge(graph, n, n);
//e == null
编辑:我说的是C-API。 还更正了函数名称。
你如何创建图表?您使用的是哪个版本的 GraphViz,使用什么操作系统?
一个适用于所有操作系统和 Graphviz 版本的方法:
Agraph_t* g = agopen("g", Agdirected, 0);
此图是非严格的,必须允许文档中编写的"自弧":
严格的图形不允许自弧或多边。
我在 Windows 上为 GraphViz 版本 2.38 和 7.1.0 对其进行了测试。对于 v2.38,它工作正常,但对于 v7.1.0,它的行为与您描述的一样。在这种情况下,允许显式创建自弧(或循环),设置 dir.no_loops = 0:
Agdesc_t dir;
dir.directed = 1; /* if edges are asymmetric */
dir.strict = 1; /* if multi-edges forbidden */
//This flag
dir.no_loop = 0; /* if no loops */
dir.maingraph = 1; /* if this is the top level graph */
dir.flatlock = 1; /* if sets are flattened into lists in cdt */
dir.no_write = 0; /* if a temporary subgraph */
dir.has_attrs = 1; /* if string attr tables should be initialized */
dir.has_cmpnd = 1; /* if may contain collapsed nodes */
g = agopen((char*)"g", dir, 0);