Layout mode (LL)
The figure Short and long link modes with orthogonal links shows a small
sample graph in short and long link modes. The short link mode bundles
the links well. Due to the bundling, some red links appear to be unconnected
to the green nodes. The algorithm cannot find a route for the long
red links without overlapping some nodes or without overlapping the
green link. The long link mode works on a grid. It is specialized
for long links and avoids overlapping any nodes or link segments.
It can connect to the green nodes by choosing connection points on
different sides of the end nodes. This advantage, however, is paid
for by a less regular structure that does not bundle the links and
a larger number of link crossings.

Short and long link modes with orthogonal links
Choosing the appropriate layout (LL)
The short link mode must be used if any of the following
conditions apply:
- Most links are short and it is not fatal if long links overlap obstacles.
- The link routes must be placed freely and cannot be restricted to a grid.
- It is important to limit the number of bends.
The long link mode must be used if any of the following
conditions apply:
- Many links are long and it is important that long links do not overlap obstacles.
- There is a preferred routing because the nodes are already placed on the grid.
- It is important to have a guaranteed minimum distance between link segments.
- An increasing number of bends is acceptable if it avoids any overlapping.
Labyrinth routing with long link layout shows how
the long link mode can be used to find an orthogonal route without
any overlapping in a labyrinth of node obstacles.

Labyrinth routing with long link layout
Link style (LL)
The layout algorithms provide two link styles. You can
set the link style globally, in which case all links have the same
shape, or locally on each link, in which case different link shapes
occur in the same drawing.
Global link style
Example of setting global link style (Link Layout algorithms)
To set the global link style:
Use the method setGlobalLinkStyle:
layout.setGlobalLinkStyle(ibm_ilog.graphlayout.shortlink.ShortLinkLayout.ORTHOGONAL_STYLE);
You can use either ibm_ilog.graphlayout.shortlink.ShortLinkLayout.ORTHOGONAL_STYLE or ibm_ilog.graphlayout.longlink.LongLinkLayout.ORTHOGONAL_STYLE,
depending on the layout that you work with. The values of both constants
are the same.
The valid values are:
- ibm_ilog.graphlayout.shortlink. ShortLinkLayout.ORTHOGONAL_STYLE or ibm_ilog.graphlayout.longlink. LongLinkLayout.ORTHOGONAL_STYLE (the default)The links are reshaped in an orthogonal form (alternating horizontal and vertical segments). See Short link layout with orthogonal links and Long link layout with orthogonal links as examples.
- ibm_ilog.graphlayout.shortlink. ShortLinkLayout.DIRECT_STYLE or ibm_ilog.graphlayout.longlink. LongLinkLayout.DIRECT_STYLEThe links are reshaped to a polygonal line composed of three segments: a straight-line segment that starts and ends with a small horizontal or vertical segment. See The same graph in short link layout with direct links as an example.
- ibm_ilog.graphlayout.shortlink. ShortLinkLayout.MIXED_STYLE or ibm_ilog.graphlayout.longlink. LongLinkLayout.MIXED_STYLEEach link can have a different link style. The style of each individual link can be set to have different link shapes occurring on the same graph.
Individual link style
All links have the same style of shape unless the global
link style is MIXED_STYLE.
Only when the global link style is set to MIXED_STYLE can
each link have an individual link style.

Different link styles mixed in the same drawing (short
link layout)

Different link styles mixed in the same drawing (long
link layout)
Example of specifying individual link style (Link Layout
algorithms)
To set and retrieve the style of an individual link:
Use the methods:
layout.setLinkStyle(link, ibm_ilog.graphlayout.shortlink.ShortLinkLayout.ORTHOGONAL_STYLE);
var style = layout.getLinkStyle(node);
The valid values are:
- ibm_ilog.graphlayout.shortlink.ShortLinkLayout.ORTHOGONAL_STYLE or ibm_ilog.graphlayout.longlink.LongLinkLayout.ORTHOGONAL_STYLE (the default)
- ibm_ilog.graphlayout.shortlink.ShortLinkLayout.DIRECT_STYLE or ibm_ilog.graphlayout.longlink.LongLinkLayout.DIRECT_STYLE
- ibm_ilog.graphlayout.shortlink.ShortLinkLayout.NO_RESHAPE_STYLE or ibm_ilog.graphlayout.longlink.LongLinkLayout.NO_RESHAPE_STYLE (that is, the link is not reshaped in any way)
End points mode (LL)
The layout algorithm provides two end point modes. You
can set the end point mode globally, in which case all end points
have the same mode, or locally on each link, in which case different
end point modes occur in the same drawing.
Global end point mode
Example of specifying global end point mode (Link Layout
algorithm)
To set the global end point mode:
Use the methods setGlobalOriginPointMode and setGlobalDestinationPointMode.
The valid values to determine the mode are:
- ibm_ilog.graphlayout.shortlink.ShortLinkLayout.FREE_MODE or ibm_ilog.graphlayout.longlink.LongLinkLayout.FREE_MODE (the default)The layout is free to choose the appropriate position of the connection point on the origin or destination node.
- ibm_ilog.graphlayout.shortlink.ShortLinkLayout.FIXED_MODE or ibm_ilog.graphlayout.longlink.LongLinkLayout.FIXED_MODEThe layout must keep the current position of the connection point on the origin or destination node.
- ibm_ilog.graphlayout.shortlink.ShortLinkLayout.MIXED_MODE or ibm_ilog.graphlayout.longlink.LongLinkLayout.MIXED_MODEEach link can have a different end point mode.
Individual end point mode
All links have the same end point mode unless the global
end point mode is MIXED_MODE.
Only when the global end point mode is set to MIXED_MODE can
each link have an individual end point mode.
Example of specifying individual end point mode (Link
Layout algorithm)
To set the mode of an individual link:
Use the methods:
layout.setOriginPointMode(link, mode)
var mode = getOriginPointMode(link)
layout.setDestinationPointMode(link, mode)
var mode = getDestinationPointMode(link)
The valid values for mode are:
- ibm_ilog.graphlayout.shortlink.ShortLinkLayout.FREE_MODEor ibm_ilog.graphlayout.longlink.LongLinkLayout.FREE_MODE (the default)
- ibm_ilog.graphlayout.shortlink.ShortLinkLayout.FIXED_MODE or ibm_ilog.graphlayout.longlink.LongLinkLayout.FIXED_MODE
Incremental mode (LL)
The Link Layout algorithm normally routes all links from
scratch. If the graph changes incrementally because you add or remove
links or nodes, the subsequent layout can differ considerably from
the previous layout. To avoid this effect and to help the user to
retain a mental map of the graph, the algorithm has an incremental
mode.
Example of enabling incremental mode (Link Layout algorithm)
To enable the incremental mode:
Use the method setIncrementalMode:
layout.setIncrementalMode(true);
In incremental mode, the layout tries to minimize the
changes to the layout. A link is only rerouted if it is new, if a
link bend has moved, if its layout parameters have changed, or if
a node was moved such that it overlaps the link.
In short link mode, if the next layout is incremental,
the links preserve the connection side and the general shape calculated
by a previous layout, except if one of their end nodes has been moved
or resized.
In long link mode, a new route is sought for the links
that are no longer on the grid or that overlap with nodes. The shape
and the connection side of the rerouted links can change completely.
Links that are already on the grid and do not overlap nodes or other
links are not rerouted in incremental mode. It is also possible to
specify which link must be rerouted by the next incremental layout
even though the layout has not changed.
Example of specifying which link must be rerouted by
the next incremental layout (Link Layout algorithm)
To select an individual link to be used for incremental
rerouting:
Use the method:
layout.markForIncremental(link)
Intergraph link routing (LL)

Nested graph with normal links (blue) and intergraph
links (red)
By default, Link Layout routes both the normal links
and the intergraph links.
Example of routing only normal links (Link Layout algorithm)
To route only normal links, disable intergraph link routing:
Use the method setInterGraphLinksMode:
layout.setInterGraphLinksMode(false);
Example of routing intergraph or normal links or both
(Link Layout algorithm)
If the intergraph links mode is enabled, you can select
whether only the intergraph links are routed or whether the intergraph
links and the normal links are routed at the same time.
Set the method setCombinedInterGraphLinksMode so
that the next layout routes the intergraph links but does not reshape
any normal links:
layout.setCombinedInterGraphLinksMode(false);
Set the method setCombinedInterGraphLinksMode so
that the next layout routes both the normal links and the intergraph
links:
layout.setCombinedInterGraphLinksMode(true);
When the intergraph links mode is enabled, the layout
cannot route the links incrementally. See Incremental mode (LL).
The layout routes only those links that belong to the
attached graph. In a nested graph, each subgraph is attached to a
different layout instance. Therefore, when starting a normal (nonrecursive)
layout for the top-level graph (see Nested graph with normal links (blue) and intergraph
links (red)), not all
links are routed that are shown in this figure, but only those links
that belong to the top-level graph.
In the following figure, the yellow shading indicates
the subgraph to which the nonrecursive link layout is currently applied.
The top-level graph is on the left and on the right is the subgraph,
which is shaded yellow. If the intergraph links mode is enabled, both
the red (intergraph) and blue (normal) links are routed. If the intergraph
links mode is disabled, only the blue (normal) links are routed. The
gray links are not routed because they do not belong to the graph
to which the link layout is applied.

Links routed in a nested graph: top-level graph and
then subgraph
To route all links of a nested graph:
- Use the default inheritance mechanism that applies the link layout specified on the top-level graph to the subgraphs also.or
- Specify a link layout explicitly on each subgraph.