A SelfLoopRouter routes the self-loops (reflexive edges) of a graph.
Remarks
Layout Style
This layout algorithm only handles the paths of self-loops, that is, edges where the source node is equal to the target node. The nodes and other edges are optionally arranged by the coreLayout.
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. The default, when there is space, is a route starting at the top and ending at the right node side.
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 an ILayoutAlgorithm which cannot handle self-loops. Then it will hide the self-loops from this coreLayout and take over the routing of them.
If no coreLayout is specified, SelfLoopRouter can work alone. It will route only the self-loops and keep the remaining graph unchanged.
Default Values of Properties
coreLayout | null | |
routingStyle | ROUNDED
|
Examples
const selfLoopRouter = new SelfLoopRouter()
const layoutData = selfLoopRouter.createLayoutData(graph)
// route only edges with a specific tag
layoutData.edges = (edge) => edge.tag == 'selected'
Type Details
- yFiles module
- algorithms
See Also
Constructors
Creates a new SelfLoopRouter with an optional coreLayout.
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.
- edgeDistance - number
- The distance between two self-loops incident to the same node. This option sets the edgeDistance property on the created object.
- routingStyle - SelfLoopRoutingStyle
- The routing style of the self-loops. This option sets the routingStyle property on the created object.
- enabled - boolean
Properties
Gets or sets the core ILayoutAlgorithm that is wrapped by this stage.
Default Value
null
.Property Value
See Also
Implements
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
.Property Value
Throws
- Exception({ name: 'ArgumentError' })
- if the specified point count is less than
1
See Also
Sample Graphs
Gets or sets the distance between two self-loops incident to the same node.
Gets or sets a value that determines whether this stage should do anything but execute the coreLayout.
Remarks
By default, when constructed, stages should be enabled. Users may disable a stage's functionality by setting this property to false
.
Stages that can guarantee that the graph will not change can choose to not even execute the coreLayout when disabled.
See Also
Implements
Gets or sets the routing style of the self-loops.
Methods
Implementation of the ILayoutAlgorithm interface and main entry point for the layout calculation.
Remarks
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- The graph to apply the layout to.
See Also
Implements
Delegates the arrangement of nodes and edges to the coreLayout and routes the self-loops.
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the input graph
See Also
Implements
createLayoutData
(graph: LayoutGraph) : EdgeScopeData<LayoutNode,LayoutEdge,LayoutNodeLabel,LayoutEdgeLabel,boolean>Returns an instance of LayoutData<TNode,TEdge,TNodeLabel,TEdgeLabel> that can be used to define the edges affected by the SelfLoopRouter.
Remarks
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the graph that determines the generic type arguments of the created layout data
Returns
- ↪EdgeScopeData<LayoutNode,LayoutEdge,LayoutNodeLabel,LayoutEdgeLabel,boolean>
- an instance of layout data that can be used to perform item-specific configurations for the given SelfLoopRouter.
Returns an instance of LayoutData<TNode,TEdge,TNodeLabel,TEdgeLabel> that can be used to define the edges affected by the SelfLoopRouter.
Remarks
Parameters
A map of options to pass to the method.
- graph - IGraph
- the graph that determines the generic type arguments of the created layout data
Returns
- ↪EdgeScopeData<INode,IEdge,ILabel,ILabel,boolean>
- an instance of layout data that can be used to perform item-specific configurations for the given SelfLoopRouter.
LayoutExecutor
type is available at runtime.Constants
A data key for determining which self-loops should be routed.
Remarks
Assign false
to edges that should keep their paths, or true
for all edges that should be routed.
If no IMapper<K,V> is registered with this key, all self-loops will be routed.
Examples
const selfLoopRouter = new SelfLoopRouter()
const layoutData = selfLoopRouter.createLayoutData(graph)
// route only edges with a specific tag
layoutData.edges = (edge) => edge.tag == 'selected'