C

OrthogonalLayout

This layout algorithm arranges graphs in an orthogonal fashion.
ImplementsInheritance Hierarchy

Remarks

Layout Style

This layout algorithm arranges the nodes of a given graph such that each edge is drawn as an alternating sequence of horizontal and vertical segments.

It produces compact drawings with no overlapping nodes, few crossings and few bends and is well suited for small and medium-sized sparse graphs.

Orthogonal drawings are common in engineering applications since they are able to provide clear representations of complex networks that can also be optimal with respect to diverse objective functions such as bend minimization or area minimization. Application domains of orthogonal drawings include software engineering, database schema representation, system management, knowledge representation, VLSI circuits and floor planning applications.

Orthogonal layout with default settings

This algorithm also optionally supports directed edge drawings (although not in combination with hierarchically nested graphs or the non-default layoutMode). Application domains of directed orthogonal drawings include, for example, software engineering, database schema and system management.

Sample output of OrthogonalLayout with default settings. Marked edges are considered directed and the layout orientation is top-to-bottom.

Sample output of OrthogonalLayout with edge grouping. All edges are considered directed and the layout orientation is left-to-right.

Also, this algorithm supports hierarchically nested graphs (although not in combination with the directed edge drawings, the from sketch option, or the non-default layoutMode):

Orthogonal layout of a grouped graph with default settings Orthogonal layout of a graph with nested groups

Concept

The orthogonal layout algorithm is based on the topology-shape-metrics approach and runs in three phases:

  • Planarization – A planar embedding is computed.
  • Orthogonalization – The bends and the angles are computed.
  • Compaction – The coordinates for the nodes and edges are determined.

Features

There exist several different main layout modes that the orthogonal layout algorithm supports depending on whether the edges should be routed completely orthogonally, or whether the original size of the nodes should be maintained. The modes are STRICT, FORCED_STRAIGHT_LINE, RELAXED, and can be specified via property layoutMode.

OrthogonalLayout is able to consider edge label data when arranging a graph. This means that the layout algorithm will determine the positions of the nodes and edges such that the edge labels do not overlap with the rest of the layout. Integrated edge labeling can be activated with the edgeLabelPlacement property.

OrthogonalLayoutEdgeDescriptor instances can be used for specifying individual information (e.g. distances) for each edge in the graph. The descriptors are bound to the graph via the layout data property edgeDescriptors. If there is no descriptor assigned to some edges, a default descriptor will be used. To set default descriptors, use defaultEdgeDescriptor.

OrthogonalLayout tries to optimize diverse objective functions such as bend minimization, number of edge crossings, edge length minimization or face maximization. Depending on the qualityTimeRatio and the specified time limit, all or only some of the optimization steps are executed.

For input graphs without group nodes, this layout algorithm is able to detect some specific substructures. If desired, it can handle and arrange them explicitly, making the structure easy to recognize. Supported substructures are trees, chains and cycles. See the corresponding style properties for details: treeSubstructureStyle, chainSubstructureStyle and cycleSubstructureStyle. For the detection of substructures, it is optionally possible to consider nodeTypes, such that only nodes of the same user-defined type can form a substructure.

This layout algorithm handles port placement constraints by applying the PortPlacementStage as a postprocessing step.

Layout Stages

This class provides a configurable pipeline that contains various ILayoutStages. Each ILayoutStage can incorporate preprocessing or postprocessing steps into the layout calculation to streamline the input graph and enhance the resulting layout. Additionally, custom ILayoutStages can be added and executed either before or after the predefined ones.

The following default ILayoutStages are included:

With these layoutStages the layout algorithm is configured well, so they usually don't need to be changed.

Default Values of Properties

NameDefaultDescription
alignDegreeOneNodesfalse
Degree-one nodes with the same neighbor are not aligned with each other.
chainSubstructureStyleOrthogonalLayoutChainSubstructureStyle.NONE
Chains are not handled explicitly.
cycleSubstructureStyleOrthogonalLayoutCycleSubstructureStyle.NONE
Cycles are not handled explicitly.
edgeLabelPlacementEdgeLabelPlacement.INTEGRATED
Edge labels are placed by the layout algorithm.
fromSketchModefalse
The initial coordinates of the nodes are not considered.
gridSpacing20
nodeLabelPlacementNodeLabelPlacement.CONSIDER
Node labels are considered.
qualityTimeRatio0.6
Quality is a bit more important than fast running time.
stopDurationTimeSpan.MAX_VALUE
The layout algorithm runs unrestricted.
treeSubstructureStyleOrthogonalLayoutTreeSubstructureStyle.NONE
Subtrees are not arranged in a special way.
uniformPortAssignmentfalse

See Also

Developer's Guide

Members

Show:

Constructors

Creates a new OrthogonalLayout instance with default settings.

Parameters

Properties

Gets or sets whether degree-one nodes that have the same neighbor should be aligned.
final

Property Value

true if the degree-one nodes are aligned, false otherwise

Default Value

The default value is: false
Degree-one nodes with the same neighbor are not aligned with each other.

Sample Graphs

ShownSetting: false
Gets or sets the minimum size (number of nodes) a chain needs to have to be detected and handled as a chain substructure.
This setting has no effect if style NONE is specified.
final

Property Value

the minimum number of nodes a chain needs to contain to be detected as a substructure

Throws

Exception ({ name: 'ArgumentError' })
if the given minimum size is less than 2

Default Value

The default value is: 4

See Also

Developer's Guide
Gets or sets the arrangement style for chain substructures.

A chain is a simple edge path where the degree of the nodes is less than or equal to 2.

Property chainSubstructureSize defines the minimum length a chain needs to have to be handled explicitly.

If there are user-defined nodeTypes, a chain substructure contains only nodes of the same type or only nodes without a type (i.e. null as type). This way, node types can be used to control which elements are allowed to form a substructure.

If a chain is part of a handled subtree (tree style other than NONE must be selected), then this chain will be arranged according to the tree substructure style and not handled as a chain substructure.
The OrthogonalLayoutChainSubstructureStyle is ignored if the input graph contains group nodes. In this case, chains are not detected and not arranged in a special way.
conversionfinal

Property Value

one of the predefined chain styles

Default Value

Chains are not handled explicitly.

See Also

Developer's Guide
Gets or sets the ComponentLayout from the layoutStages of this instance.
If you need to replace the instance, modify the layoutStages stack using replace. If you want to remove a stage, consider disabling it instead.
readonlyfinal

Throws

Exception ({ name: 'InvalidOperationError' })
If there is no instance of the respective type in the layoutStages
Gets or sets the minimum size (number of nodes) a cycle needs to have to be detected and explicitly handled as a cycle substructure.
This setting has no effect if style NONE is specified.
final

Property Value

the minimum number of nodes a cycle needs to contain to be detected as a substructure

Throws

Exception ({ name: 'ArgumentError' })
if the given minimum size is less than 4

Default Value

The default value is: 4

See Also

Developer's Guide
Gets or sets the arrangement style for cycle substructures.

A cycle is a simple edge path where the first and last node are identical. The algorithm only considers cycles where at most one edge connects a cycle node with the rest of the graph (i.e. isolated cycles that are connected with one edge).

If there are user-defined nodeTypes, a cycle contains only nodes of the same type or only nodes without a type (i.e. null as type). This way, node types can be used to control which elements are allowed to form a substructure.

The OrthogonalLayoutCycleSubstructureStyle is ignored if the input graph contains group nodes. In this case, cycles are not detected and not arranged in a special way.
conversionfinal

Property Value

one of the predefined cycle styles

Default Value

Cycles are not handled explicitly.

See Also

Developer's Guide
Gets or sets the OrthogonalLayoutEdgeDescriptor instance used for all those edges that do not have a specific descriptor assigned.
To define individual settings per item (edge), use the layout data property edgeDescriptors.
final

Property Value

the current OrthogonalLayoutEdgeDescriptor instance

Throws

Exception ({ name: 'ArgumentError' })
if the specified OrthogonalLayoutEdgeDescriptor is null

Default Value

The default value is: OrthogonalLayoutEdgeDescriptor
A descriptor instance with default settings.

See Also

Developer's Guide
API
edgeDescriptors
Gets or sets how the layout handles the position of edge labels.
conversionfinal

Property Value

INTEGRATED if the layout algorithm places the edge labels avoiding overlaps, IGNORE if the edge labels are ignored by the layout algorithm, and GENERIC if the edge labels are placed by the GenericLabeling algorithm subsequently.

Default Value

The default value is: EdgeLabelPlacement.INTEGRATED
Edge labels are placed by the layout algorithm.

Sample Graphs

ShownSetting: IGNORE

See Also

Developer's Guide
Gets or sets whether the existing drawing should be used as a sketch of the resulting orthogonal layout.
The layout algorithm will try to orthogonalize the given sketch without making too many modifications with respect to the original drawing.
If this option is enabled, the existing drawing should be preserved as much as possible.
This implementation can not use the sketch as input if there are group nodes in the graph. This property will be ignored if group nodes exist in the graph component
final

Property Value

true if the existing drawing is used as a sketch, false otherwise

Default Value

The default value is: false
The initial coordinates of the nodes are not considered.

Sample Graphs

ShownSetting: Initial drawing

See Also

Developer's Guide
Gets or sets the equidistant spacing between the horizontal and vertical grid lines.

Each node will be placed on a grid point. Edges will be routed such that all segments but the first and last one lie on grid lines. (The first and last segments of an edge may or may not lie on grid lines.) Edges consisting of a single segment always lie on grid lines.

The grid spacing has to be greater than 0.

This option is only guaranteed if the layoutMode is set to STRICT. For all other modes, it is used as a hint only.
final

Property Value

the grid spacing

Throws

Exception ({ name: 'ArgumentError' })
if the grid spacing is negative

Default Value

The default value is: 20

Sample Graphs

ShownSetting: Grid spacing 20.

See Also

Developer's Guide
Gets or sets the layoutOrientation of the OrientationStage.
Only the directed orthogonal edges consider the specified layout orientation.
conversionfinal

See Also

Developer's Guide
Gets or sets how the layout handles the position of node labels.
conversionfinal

Property Value

CONSIDER if the layout algorithm takes the position and sizes of the node labels into account, IGNORE if the node labels are ignored by the layout algorithm, and GENERIC if the node labels are placed by the GenericLabeling algorithm subsequently.

Default Value

The default value is: NodeLabelPlacement.CONSIDER
Node labels are considered.

Sample Graphs

ShownSetting: IGNORE

See Also

Developer's Guide
Gets or sets whether parallel routes for parallel edges (multi-edges) are preferred over independent routes.

When enabled, the algorithm routes multi-edges (edges that connect the same pair of nodes) in parallel, i.e., these edges connect to the same side of the nodes and have the same or a similar path. Note that the path is not always exactly the same since the algorithm has to omit label-edge intersections if edgeLabelPlacement is set to INTEGRATED. If this setting is disabled, the edges are simply independent and might as well connect to different node sides and get very different paths.

A parallel routing is suitable for a lot of diagrams (especially larger ones) as it helps to better recognize multi-edge structures. However, there are scenarios where the routes of such edges might as well be independent. For small examples the structure can also be clear if the edges connect to other node sides, especially when they are in consecutive order around the node.

This property only affects edges that share the same source and target node.
This setting is ignored if the ILayoutStage ParallelEdgeRouter is enabled, that is, if parallel edges are not handled by this layout algorithm internally but by the separate stage.
final

Property Value

true if parallel edges are routed in parallel, false otherwise

Default Value

The default value is: true
The algorithm tries to route parallel edges in parallel.

Sample Graphs

ShownSetting: true
Gets or sets the ratio of layout quality versus running time.

The larger the ratio, the better the quality of the resulting layout but the longer it may take to perform the layout calculation.

The value needs to lie within [0,1].

final

Property Value

a value between 0.0 (low quality, fast) and 1.0 (high quality, slow)

Throws

Exception ({ name: 'ArgumentError' })
if the specified ratio is outside the interval [0,1]

Default Value

The default value is: 0.6
Quality is a bit more important than fast running time.
Gets or sets the preferred time limit.

Depending on the specified value and the size of the input graph, the layout algorithm may automatically disable some internal optimization steps that can improve the layout quality but also increase the runtime, especially for larger graphs. If the time limit is set to MAX_VALUE, the layout algorithm runs unrestricted.

Values have to be greater or equal to ZERO.

Restricting the stop duration may result in a lower layout quality. Furthermore, the real runtime may exceed the stop duration since the layout algorithm still has to find a valid solution.
conversionfinal

Property Value

a non-negative value that specifies the preferred time limit

Throws

Exception ({ name: 'ArgumentError' })
if the stop duration is negative

Default Value

The default value is: TimeSpan.MAX_VALUE
The layout algorithm runs unrestricted.

See Also

Developer's Guide
Gets or sets the desired orientation for tree substructure layouts.
This orientation affects only trees that are specifically handled as a tree substructure when the tree style is not NONE. It is independent of the main layoutOrientation. For example, the main orientation could be top-to-bottom while the subtree orientation is left-to-right at the same time.
This property has no effect if NONE is set as tree style.
conversionfinal

Property Value

one of the four default layout orientations or AUTO_DETECT

Default Value

The tree orientation is determined automatically.

See Also

Developer's Guide
Gets or sets the minimum size (number of nodes) a subtree needs to have to be detected and explicitly handled as a tree substructure.
This setting has no effect if style NONE is specified.
final

Property Value

the minimum number of nodes a tree needs to contain to be detected as a substructure

Throws

Exception ({ name: 'ArgumentError' })
if the given minimum size is less than 3

Default Value

The default value is: 3

See Also

Developer's Guide
Gets or sets the arrangement style for tree substructures.
If there are user-defined nodeTypes, a subtree contains only nodes of the same type or only nodes without a type (i.e. null as type). This way, node types can be used to control which elements are allowed to form a substructure.
The identified subtrees do never contain parallel edges (multiple edges between the same endpoints).
The OrthogonalLayoutTreeSubstructureStyle is ignored if the input graph contains group nodes. In this case, trees are not detected and not arranged in a special way.
Tree edges that connect to the subtree root node are never grouped together with non-tree edges connecting to the root node. Edge grouping constraints for these edges are ignored.
conversionfinal

Property Value

one of the predefined tree styles

Default Value

Subtrees are not arranged in a special way.

See Also

Developer's Guide
Gets or sets whether the layout algorithm should try to obtain a uniform port assignment of the edges incident to the same node side.
If this option is enabled, the algorithm may insert additional bends in order to obtain a more uniform port assignment.
If option fromSketchMode is enabled, the algorithm doesn't insert additional bends which may result in non-uniform ports even though this option is enabled.
This option can only be considered for layout mode STRICT.
final

Property Value

true if the port assignment is uniform, false otherwise

Default Value

The default value is: false

Sample Graphs

ShownSetting: true

See Also

Developer's Guide

Methods

Calculates an orthogonal layout for the given graph.
The given graph will not be copied during the layout process and the result will be immediately applied to the input graph.
This method is not side effect-free in the sense that the order of edges or nodes in the input graph may change during the layout process.

Parameters

graph: LayoutGraph
the input graph
Calculates an orthogonal layout for the given graph.
The given graph will not be copied during the layout process and the result will be immediately applied to the input graph.
This method is not side effect-free in the sense that the order of edges or nodes in the input graph may change during the layout process.
protectedfinal

Parameters

graph: LayoutGraph
the input graph
Returns an instance of LayoutData<TNode, TEdge, TNodeLabel, TEdgeLabel> that can be used to perform item-specific configurations for the OrthogonalLayout.
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

OrthogonalLayoutData<LayoutNode, LayoutEdge, LayoutNodeLabel, LayoutEdgeLabel>
an instance of layout data that can be used to perform item-specific configurations for the given OrthogonalLayout.
Returns an instance of LayoutData<TNode, TEdge, TNodeLabel, TEdgeLabel> that can be used to perform item-specific configurations for the OrthogonalLayout.
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

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

Constants

All constants are filtered. Go to Filters.