Self-links that start and end at the same node

Self-links are links that start and end at the same node. They can even occur as multiple links, when they are called multiself-link bundle. When links are routed straight, self-links are not visible, because they start and end at the same point in the center of the node. To avoid this effect, the layouts listed in Layout algorithms that are subclasses of Basic Link Style Layout have a self-link mode that is applied only when the link style is set to STRAIGHT_LINE_STYLE. In spite of the name of the link style, the combination of mode and style causes bends to be added to the self-links to make them visible. When the link style is NO_RESHAPE_STYLE, self-link mode has no effect.
Example of specifying how self-links are routed
All these modes, except the no-bends mode, create three bends placed orthogonally, so that the segments approximately resemble three-quarters of a rectangle or of a square, the fourth quarter being the node where the self-link is attached. Depending on the node dimension, the rectangular modes create four-cornered shapes that are not squares; the square modes create squares. The square modes are useful for spline self-links in particular, because the spline can then approximately resemble three-quarters of a circle.
Mode Graphical result
CONNECTED_RECTANGULAR mode
Connected
rectangular mode resulting in self-link with three orthogonal bends
CONNECTED_SQUARE mode
Connected
square mode resulting in self-link with three orthogonal bends
CONNECTED_SQUARE mode with spline link
Connected
square mode resulting in spline self-link
The connected modes place the connection points at the border of the node. The free modes place the bends at the same position as the corresponding connected modes, but the link connection point is not enforced; that is, the node and link are free to select where to place the connection point. The link segments in the free modes might not be orthogonal, because the connection point is not enforced.
The narrow modes and the other modes behave the same for single self-links. If you have multiple self-links at the same node, the self-links are shifted by an offset to avoid overlaps. In this case, the narrow modes differ from the other modes; the multiself-link bundle may appear narrower, because the shift offset of the multiple self-links is limited by the size of the end node.
Examples of use of mode and offset Graphical result
CONNECTED_SQUARE mode
Shift
offset of multiple self-links in connected square mode
NARROW_CONNECTED_SQUARE mode
Shift
offset of multiple self-links limited by the size of the end node
in narrow connected square mode
Self-links can occur at all four corners of the node. The algorithm determines automatically which corner is most appropriate, depending on the direction of all other links. You can restrict which corner should be used.
Use the method:
layout.setSelfLinkAllowedCorners(corners);
By default, self-links are oriented clockwise. You can specify other orientations.
Use the method:
setSelfLinkOrientation(orientation);
Using Force-directed layout as an example, the valid values for orientation are: