Multiple links between the same pair of nodes

Sometimes a graph has multiple links between the same pair of nodes. When these links are routed straight and use the same connection point at the nodes, they overlap and cannot be distinguished. To avoid such overlaps, the specified layouts have a multilink mode that is applied only when the link style is set to STRAIGHT_LINE_STYLE. This mode has no effect when the link style is NO_RESHAPE_STYLE.
Example of specifying how multiple links are routed
To specify the multilink mode, use the method:
layout.setMultiLinkMode(mode);
The valid values for mode are given with the example of Force-directed layout:
If the multilink mode is not NO_BUNDLE, the offset between the shifted links or between the bends of the links respectively can be specified:
Use the methods:
layout.setMultiLinkOffset(offset);
layout.setMultiLinkMaxSpread(maxSpread);
The multilink offset is the offset between two neighboring links (or their bends). The value of maxSpread limits this offset to avoid having too much space used when you have too many multiple links. If the multilink offset is 10 and the value of maxSpread is 60, the effective offset is 10 if you have less than six multilinks. If you have more multilinks, the effective offset is reduced. For example, if you have 15 multilinks, the effective offset will be 4 instead of 10 to ensure that the links are shifted at most 60 units apart from each other. If the multilink mode is NARROW_STRAIGHT_LINE_BUNDLE, the effective offset is further limited by the size of the bounding box of both end nodes of a link bundle.
Examples of use of mode and offset Graphical result
NO_BUNDLE
Result
of offset in NO_BUNDLE mode between a pair of links
STRAIGHT_LINE_BUNDLE when the value of maxSpread is set too high.
Result
of offset in STRAIGHT_LINE_BUNDLE with the value of max spread set
too high
NARROW_STRAIGHT_LINE_BUNDLE: the same result can be obtained with STRAIGHT_LINE_BUNDLE by reducing the value of maxSpread.
Result
of offset in NARROW_STRAIGHT_LINE_BUNDLE or in STRAIGHT_LINE_BUNDLE
with a reduced value of max spread
CONNECTED_ONE_BEND_BUNDLE
Result
of offset in CONNECTED_ONE_BEND_BUNDLE
FREE_ONE_BEND_BUNDLE when the links are initially attached to node centers.
The same result can be obtained with CONNECTED_ONE_BEND_BUNDLE in combination with setting connectLinksToNodeCenters to true. For example, see ibm_ilog.graphlayout.forcedirected.ForceDirectedLayout.setConnectLinksToNodeCenters
Result
of offset in FREE_ONE_BEND_BUNDLE, links initially attached to node
centers, or CONNECTED_ONE_BEND_BUNDLE with setConnectLinksToNodeCenters
set to true