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:
- ibm_ilog.graphlayout.forcedirected.ForceDirectedLayout.NO_BUNDLE: Multiple links between the same pair of nodes are not treated in any special way. They are not spread out and might overlap.
- ibm_ilog.graphlayout.forcedirected.ForceDirectedLayout.STRAIGHT_LINE_BUNDLE: Multiple links between the same pair of nodes are routed as straight lines, but shifted relative to each other to avoid overlaps. Contrary to the narrow mode, the shift offset is not limited by the node size.
- ibm_ilog.graphlayout.forcedirected.ForceDirectedLayout.NARROW_STRAIGHT_LINE_BUNDLE: Similar to the straight line bundle mode, but the shift offset is limited by the size of the two end nodes of the link bundle and therefore can appear narrower. When you have too many multiple links between the same pair of nodes, this mode avoids shifting the links so far away that they no longer appear connected to the nodes. This mode is the default.
- ibm_ilog.graphlayout.forcedirected.ForceDirectedLayout.CONNECTED_ONE_BEND_BUNDLE: Multiple links between the same pair of nodes are routed with one bend to avoid overlaps. All links in the bundle start at the same connection point and end at the same connection point.
- ibm_ilog.graphlayout.forcedirected.ForceDirectedLayout.FREE_ONE_BEND_BUNDLE: Multiple links between the same pair of nodes are routed with one bend to avoid overlaps. Contrary to the connected one bend bundle mode, the link connection point is not enforced; that is, the node and link are free to place the connection point. There is no guarantee that all links of the bundle start or end at a common point.
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 | ![]() |
STRAIGHT_LINE_BUNDLE when the value of maxSpread is set too high. | ![]() |
NARROW_STRAIGHT_LINE_BUNDLE: the same result can be obtained with STRAIGHT_LINE_BUNDLE by reducing the value of maxSpread. | ![]() |
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
|
![]() |