C

SelfLoopRouter

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.

Small graph with self-loops

Concept

Self-loops are handled in four steps:

  1. Remove all self-loops of the input graph
  2. Invoke the core layout algorithm on the now self-loops free graph
  3. Reinsert all formerly removed self-loops
  4. 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.

Examples

To only include some self-loops in the routing process, define those self-loops using the EdgeScopeData<TNode, TEdge, TNodeLabel, TEdgeLabel, TEdgeScope>.
Creating an instance of EdgeScopeData
const selfLoopRouter = new SelfLoopRouter()
const layoutData = selfLoopRouter.createLayoutData(graph)

// route only edges with a specific tag
layoutData.edges = (edge) => edge.tag == 'selected'

Default Values of Properties

NameDefault
coreLayoutnull
routingStyleSelfLoopRoutingStyle.ROUNDED

See Also

Developer's Guide

Members

Show:

Constructors

Creates a new SelfLoopRouter with an optional coreLayout.

Parameters

coreLayout?: ILayoutAlgorithm
The core layout algorithm.

Properties

Gets or sets the core ILayoutAlgorithm that is wrapped by this stage.
final

Property Value

the core layout routine

Default Value

The default value is: null
Gets or sets the number of points that are used for rounding the corners of the self-loops.

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.

This option is only considered when style ROUNDED is used.
final

Property Value

the number of bends that are inserted to round the corners of self-loops

Throws

Exception ({ name: 'ArgumentError' })
if the specified point count is less than 1

Default Value

The default value is: 2

Sample Graphs

ShownSetting: 2

See Also

API
routingStyle, ROUNDED
Gets or sets the distance between two self-loops incident to the same node.
The distance needs to be a non-negative value.
This value is only considered for routing style ROUNDED.
final

Property Value

the distance between the self-loops

Throws

Exception ({ name: 'ArgumentError' })
if the specified distance is negative

Default Value

The default value is: 5

Sample Graphs

ShownSetting: 5

See Also

API
ROUNDED
Gets or sets a value that determines whether this stage should do anything but execute the coreLayout.

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.

final
Gets or sets the routing style of the self-loops.
conversionfinal

Property Value

the routing style for self-loops

Default Value

The default value is: SelfLoopRoutingStyle.ROUNDED

Methods

Implementation of the ILayoutAlgorithm interface and main entry point for the layout calculation.
This implementation checks the enabled state and when it's not enabled, will delegate to the coreLayout, directly. When the stage is enabled, all the work will be delegated to applyLayoutImpl, instead.
final

Parameters

graph: LayoutGraph
The graph to apply the layout to.
Delegates the arrangement of nodes and edges to the coreLayout and routes the self-loops.
protected

Parameters

graph: LayoutGraph
the input graph
Returns an instance of LayoutData<TNode, TEdge, TNodeLabel, TEdgeLabel> that can be used to define the edges affected by the SelfLoopRouter.
The generic type arguments of the created layout data are compatible with instances of LayoutGraph, but the layout data is not bound to a specific graph instance. Therefore, the created layout data still has to be passed as an argument of applyLayout in order to be applied.

Parameters

graph: LayoutGraph
the graph that determines the generic type arguments of the created layout data

Return Value

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.
The generic type arguments of the created layout data are compatible with instances of IGraph, but the layout data is not bound to a specific graph instance. Therefore, the created layout data still has to be passed as an argument of applyLayout in order to be applied.
This method is not available unless the module view-layout-bridge is loaded. Either load the module 'view-layout-bridge' explicitly or ensure that the LayoutExecutor type is available at runtime.

Parameters

graph?: IGraph
the graph that determines the generic type arguments of the created layout data

Return Value

EdgeScopeData<INode, IEdge, ILabel, ILabel, boolean>
an instance of layout data that can be used to perform item-specific configurations for the given SelfLoopRouter.

Constants

All constants are filtered. Go to Filters.