headport 和 tailport 功能在 graphviz 中不起作用

headport and tailport functionality not working in graphviz

“headport”和“tailport”的 documentation 表示它指示 head/tail 节点上附加边缘 head/tail 的位置。在默认情况下,边缘指向节点的中心,然后在节点边界处被裁剪。 下面给出的代码-

digraph G {
  graph [ rankdir =LR ];
  "struct1" [ shape =record, label = "a|b|<port1>c" ];
  "struct2" [ shape =record, label = "a|{<port2>b1|b2}|c" ];
  "struct1" -> "struct2" [ headport = "port1", tailport = "port2" ];
}

应该生成一条从 node:struct1 端口“c”到 node:struct2 端口“b1”的边,像这样(左)-

但是它会使用默认行为生成这样的边(右)。 我知道 struct1:port1 -> struct2:port2 [ label="xyz" ]; 可以用于此目的,但我不知道如何使用 addEdge 方法生成这样的点字符串(开放建议)。

用于生成上述点格式表示的代码如下-

var util = require('util'),
  graphviz = require('graphviz');

var g = graphviz.digraph("G");
g.set("rankdir","LR")

var n1 = g.addNode( "struct1", {"shape":"record","label":"a|b|<port1>c"} );
var n2 = g.addNode( "struct2", {"shape":"record","label":"a|{<port2>b1|b2}|c"} );
g.addEdge(n1,n2,{"headport":"port1","tailport":"port2"});

console.log( g.to_dot() );

我请求社区帮助我生成如图 1 所示的边缘。 我也尝试过其他版本的端口属性参数,例如 such , "c","port0:c" 等但没有用。

文档有点模糊,但您误用了 headport/tailport。 headport/tailport 应该是罗盘点。这是一个正确的例子:

tailport=ne headport=s

这是对代码的修复,使用 fieldid -(此处不需要端口):

digraph G {
  graph [ rankdir =LR ];
  "struct1" [ shape =record, label = "a|b|<port1>c" ];
  "struct2" [ shape =record, label = "a|{<port2>b1|b2}|c" ];
  struct1:port1 -> struct2:port2 
}