A SelfLoopRouter routes the self-loops (reflexive edges) of a graph.
Remarks
Layout Style
The nodes and normal edges are arranged by the core layout algorithm. This layout algorithm only handles the paths of self-loops.
Self-loops are routed either orthogonal or with rounded corners. The layout algorithm places the self-loops in the least crowded quadrant around a node.
Concept
Self-loops are handled in four steps:
- Remove all self-loops of the input graph
- Invoke the core layout algorithm on the now self-loops free graph
- Reinsert all formerly removed self-loops
- Route the self-loops of the input graph
Features
SelfLoopRouter can either be used as a ILayoutStage wrapping a layout algorithm which cannot handle self-loops. Then it will hide the self-loops from this core layout algorithm and take over the routing of them.
If no core layout algorithm is specified, SelfLoopRouter can work alone. It will route only the self-loops and keep the remaining graph unchanged.
When all self-loops already have a suitable layout, this layout algorithm can keep the self-loop paths. It will just hide the self-loops before invoking the core layout algorithm, such that they are not altered by it.
To only exclude some self-loops from routing, a IDataProvider registered with KEEP_SELF_LOOP_LAYOUT_DP_KEY can be used for marking those self-loops.
Default Values of Properties
coreLayout | null | |
keepAllSelfLoopRoutes | false | Self-loops get a new route. |
layoutStyle | ROUNDED
| |
smartSelfLoopPlacement | true | The corner of the nodes where self-loops are placed is chosen considering incident edges. |
Type Details
- yfiles module
- layout-core
- yfiles-umd modules
- All layout modules, view-layout-bridge
- Legacy UMD name
- yfiles.layout.SelfLoopRouter
See Also
Constructors
Creates a new SelfLoopRouter with an optional core layout algorithm.
Parameters
A map of options to pass to the method.
- coreLayout - ILayoutAlgorithm
- The core layout algorithm.
- cornerApproximationPointsCount - number
The number of points that are used for rounding the corners of the self-loops. This option sets the cornerApproximationPointsCount property on the created object.
- lineDistance - number
The distance between two self-loops incident to the same node. This option sets the lineDistance property on the created object.
- smartSelfLoopPlacement - boolean
Whether or not the algorithm chooses the side of the self-loop depending on the incident edges. This option sets the smartSelfLoopPlacement property on the created object.
- layoutStyle - SelfLoopStyle
The layout style of the self-loops. This option sets the layoutStyle property on the created object.
- keepAllSelfLoopRoutes - boolean
Whether or not this algorithm should keep all self-loop routes. This option sets the keepAllSelfLoopRoutes property on the created object.
Properties
Gets or sets the core layout algorithm that is wrapped by this stage.
Gets or sets the number of points that are used for rounding the corners of the self-loops.
Remarks
For rounded corners, the number of points should be at least 2
. All smaller values will produce one bend and, therefore, an orthogonal path.
The number of points for a corner must be at least 1
.
Default Value
2
.Throws
- Exception({ name: 'ArgumentError' })
- if the specified point count is less than
1
See Also
Sample Graphs
Gets or sets whether or not this algorithm should keep all self-loop routes.
Remarks
Default Value
false
.Self-loops get a new route.
Gets or sets the distance between two self-loops incident to the same node.
Gets or sets whether or not the algorithm chooses the side of the self-loop depending on the incident edges.
Remarks
Default Value
true
.The corner of the nodes where self-loops are placed is chosen considering incident edges.
Sample Graphs
Methods
Delegates the arrangement of nodes and edges to the core layout algorithm and routes the self-loops.
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the input graph
See Also
Implements
Invokes the layout process of the core layout algorithm.
Remarks
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the input graph
See Also
Defined in
Calculates the routes of the self-loops in the given graph.
Remarks
This method will only change the routes of self-loops that are not marked to be kept.
This method is called by applyLayout after the core layout algorithm has arranged the graph and all self-loops have been reinserted into the graph. It may be overridden to introduce custom self-loop styles.
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the input graph
Constants
A data provider key for determining which self-loops should keep their current path.
Remarks
Domain | Edge | |
Values | boolean | true for edges that keep their paths, false or null for all edges that are routed |