Increase the spacing between the links in a layered digraph layout with groups

I have made a network with layered digraph layout in both the diagram and the 2 groups(image shown).The position of the nodes in the group and the different layers of the diagram is fine but the links are overlapping(enclosed within the red boundary). What should I set to space out the links?

Set LayeredDigraphLayout.linkSpacing to something like 10. That should help with your middle circled link segments and maybe elsewhere too.

For the links in your left circled area, you need to automatically assign different values of Link.toEndSegmentLength, probably in an override of LayeredDigraphLayout.commitLinks. I’ll experiment with this for you later today or next week.

thanks…the overlapping in the middle circle has been resolved by setting linkSpacing to 20. Please look into the other two also.

Try this:

  function CustomLink() {;
  go.Diagram.inherit(CustomLink, go.Link);

  /** @override */
  CustomLink.prototype.computeEndSegmentLength = function(node, port, spot, from) {
    var esl =, node, port, spot, from);
    var group = node.containingGroup;
    if (group === null) return esl;

    var other = this.getOtherPort(port);
    if (port !== null && other !== null && other.part.containingGroup !== group) {
      var thispt = port.getDocumentPoint(this.computeSpot(from));
      var otherpt = other.getDocumentPoint(this.computeSpot(!from));
      if (Math.abs(thispt.x - otherpt.x) > 20 || Math.abs(thispt.y - otherpt.y) > 20) {
        var gb = group.actualBounds;
        var np =;
        var dist = Math.min(Math.abs(, Math.abs(np.y-gb.bottom));
        return esl + dist/8;
    return esl;

This is adapted from the CustomLink class from the Dynamic Ports sample. But in your case it tries to produce different …EndSegmentLengths based on the relative vertical location of the node within its containing group.