The documentation for "headport" and "tailport" says that it Indicates where on the head/tail node to attach the head/tail of the edge. In the default case, the edge is aimed towards the center of the node, and then clipped at the node boundary. The code given below -
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" ];
}
should generate an edge from node:struct1 port "c" to node:struct2 port "b1" like this(left) -
however it generates an edge like this(right),using default behavior.
I understand that struct1:port1 -> struct2:port2 [ label="xyz" ];
can be used for the purpose ,but I don't know how to use addEdge method to generate such a dot string (open to suggestions ).
The code used to generate the above dot format representation is below -
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() );
I request the community to please help me generate an edge like in image 1. I have also tried other versions of port attribute argument such as such , "c","port0:c" etc yet no use.
The documentation is a bit fuzzy, but you are misusing headport/tailport. headport/tailport should be compass points. Here is a correct example:
tailport=ne headport=s
Here is a fix to the code, using fieldid - (port not needed here):
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
}