This class represents a partial layout algorithm which changes the coordinates for a given set of graph elements (called partial elements) only.
Remarks
The location and size of the remaining elements (called fixed elements) is not allowed to be changed.
Layout Style
This partial layout algorithm offers a kind of generic partial layout support for other existing layout algorithms. Hence, its layout style heavily depends on the selected coreLayout as well as the specified edgeRouter or edgeRoutingStyle.
The partial layout is suitable for applications where users may incrementally add new elements to an existing drawing. The added elements should be arranged so that they fit best possible into the given diagram without making any changes to the already existing layout. Hence, the so-called mental map of the existing drawing is preserved.
Features
Similar to the layout style, the supported feature set mainly depends on the features supported by the specified coreLayout as well as the specified edgeRouter or edgeRoutingStyle. The internal step that places the components can handle group nodes and is able to consider minimum distance constraints and node labels.
Furthermore, the algorithm tries to place a subgraph component within the associated cell of the LayoutGrid. For this feature to work properly it is required that the values of the properties position, position, width and height are correctly specified. Note that the algorithm does not guarantee that the calculated subgraph layout fits into the grid cell.
Concept
The layout algorithm tries to place the partial elements such that the resulting drawing (including the fixed elements) has a good quality with respect to common graph drawing aesthetics.
The layout algorithm handles each selected graph element as partial element. Selected graph elements can be defined using properties scope. Partial node elements can be assigned to the so-called subgraph components. During the layout process each subgraph induced by the nodes of a component is first laid out using the specified coreLayout. Then, the different components are placed one-by-one onto the drawing area such that the number of overlaps among graph elements is small. The user can specify different objectives for finding 'good' positions for subgraph components (see subgraphPlacement), e.g., BARYCENTER specifies that the component should be placed close to the barycenter of its graph neighbors and FROM_SKETCH specifies that the component should be placed close to its original position.
Method componentAssignmentStrategy allows to specify the strategy that assigns partial nodes to subgraph components. Possible values are CLUSTERING, CONNECTED, and SINGLE. Note that nodes of a component cannot be assigned to different group nodes.
Furthermore, the user can specify the edge routing style (see edgeRoutingStyle) that is used for routing partial edges and edges between different subgraph components (so-called inter-edges). Possible values are ORGANIC, ORTHOGONAL, STRAIGHT_LINE, OCTILINEAR and AUTOMATIC.
Default Values of Properties
allowMirroring | false | Mirroring is disabled. |
allowMovingFixedElements | false | The algorithm doesn't move fixed elements. |
componentAssignmentStrategy | SINGLE
| Each partial node is assigned to a separate subgraph component. |
componentCompaction | true | Subgraph component may be placed within another subgraph component. |
considerNodeAlignment | false | Nodes are not aligned. |
edgeRouter | StraightLineEdgeRouter
| |
edgeRoutingStyle | STRAIGHT_LINE
| |
layoutOrientation | NONE
| The layout orientation is completely ignored. |
minimumNodeDistance | 10 | |
optimizeOrientation | true | This postprocessing step is enabled. |
resizeFixedGroups | false | Fixed group nodes may not be resized. |
routeInterEdgesImmediately | false | Edges are not routed immediately. |
stopDuration | MAX_VALUE
| The time is not limited. |
subgraphPlacement | BARYCENTER
| Each subgraph component is placed close to the barycenter of its graph neighbors. |
Type Details
- yFiles module
- algorithms
Constructors
Creates a new instance of PartialLayout which uses the specified ILayoutAlgorithm instance as the core layout algorithm.
Remarks
Parameters
A map of options to pass to the method.
- coreLayout - ILayoutAlgorithm
- the layout algorithm that is applied to the subgraph components
- allowMovingFixedElements - boolean
- Whether or not the algorithm may move fixed elements. This option sets the allowMovingFixedElements property on the created object.
- stopDuration - TimeSpan
- The preferred time limit for the layout algorithm. This option sets the stopDuration property on the created object.
- routeInterEdgesImmediately - boolean
- Whether or not edges between different subgraph components should be routed immediately. This option sets the routeInterEdgesImmediately property on the created object.
- componentCompaction - boolean
- Whether or not a subgraph component may be placed within another subgraph component. This option sets the componentCompaction property on the created object.
- resizeFixedGroups - boolean
- Whether or not fixed (non-partial) group nodes may be resized. This option sets the resizeFixedGroups property on the created object.
- subgraphPlacement - SubgraphPlacement
- The objective used for finding 'good' positions for subgraph components. This option sets the subgraphPlacement property on the created object.
- minimumNodeDistance - number
- The minimum distance between two adjacent nodes. This option sets the minimumNodeDistance property on the created object.
- considerNodeAlignment - boolean
- Whether or not partial nodes should be aligned. This option sets the considerNodeAlignment property on the created object.
- componentAssignmentStrategy - ComponentAssignmentStrategy
- The strategy that assigns partial nodes to subgraph components. This option sets the componentAssignmentStrategy property on the created object.
- optimizeOrientation - boolean
- Whether or not a postprocessing step should be applied to reduce the number of directed edges that do not comply with the specified layout orientation. This option sets the optimizeOrientation property on the created object.
- edgeRouter - ILayoutAlgorithm
- The custom edge router instance that is used for partial edges and edges between different subgraph components (so-called inter-edges). This option sets the edgeRouter property on the created object.
- edgeRoutingStyle - PartialLayoutRoutingStyle
- The routing style that is used for partial edges and inter-edges. This option sets the edgeRoutingStyle property on the created object.
- layoutOrientation - PartialLayoutOrientation
- The layout orientation that is considered during the placement of partial elements. This option sets the layoutOrientation property on the created object.
- allowMirroring - boolean
- Whether subgraph components may be mirrored to improve the layout quality. This option sets the allowMirroring property on the created object.
- enabled - boolean
See Also
Properties
Gets or sets whether subgraph components may be mirrored to improve the layout quality.
Remarks
Default Value
false
.Mirroring is disabled.
Property Value
true
if subgraph components are mirrored, false
otherwiseSample Graphs
Gets or sets whether or not the algorithm may move fixed elements.
Remarks
Default Value
false
.The algorithm doesn't move fixed elements.
Property Value
true
if the algorithm may move fixed elements, false
otherwise.Gets or sets the strategy that assigns partial nodes to subgraph components.
Remarks
To define custom components instead of using the predefined strategies, use componentIds. In this case, the value of componentAssignmentStrategy will be ignored.
The specified coreLayout independently calculates the layout for each subgraph component.
- SINGLE: each partial node is a separate subgraph component. The specified core layout doesn't have any effect because it is applied to each single node separately.
- CONNECTED: components are defined by the connected components of the graph induced by the partial elements.
- CLUSTERING: components are defined by edge betweenness clustering.
Default Value
Property Value
See Also
Sample Graphs
Gets or sets whether or not a subgraph component may be placed within another subgraph component.
Remarks
Default Value
true
.Subgraph component may be placed within another subgraph component.
Property Value
true
if a subgraph component may be placed within another subgraph component, false
otherwiseGets or sets whether or not partial nodes should be aligned.
Remarks
Default Value
false
.Nodes are not aligned.
Property Value
true
if nodes are aligned, false
otherwiseSample Graphs
Gets or sets the core ILayoutAlgorithm that is wrapped by this stage.
Gets or sets the custom edge router instance that is used for partial edges and edges between different subgraph components (so-called inter-edges).
Default Value
StraightLineEdgeRouter.Property Value
See Also
Gets or sets the routing style that is used for partial edges and inter-edges.
Remarks
- STRAIGHT_LINE produces straight-line edge routes.
- ORTHOGONAL produces orthogonal edge routes.
- OCTILINEAR produces octilinear edge routes.
- ORGANIC produces organic edge routes.
- AUTOMATIC automatically chooses a suitable style for the partial edges inter-edges, based on the existing routes of the fixed edges.
Default Value
STRAIGHT_LINE.Property Value
See Also
Sample Graphs
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.
Implements
Gets or sets the layout orientation that is considered during the placement of partial elements.
Remarks
v
is placed before v
and each successor after v
with respect to the layout orientation.- NONE: the layout orientation is completely ignored.
- AUTO_DETECT: the layout orientation is automatically detected. The algorithm analyzes the flow direction of fixed edges in the current drawing. If there is no common flow direction, the results are the same as for NONE. Otherwise, the layout orientation is one of the four main orientations.
- TOP_TO_BOTTOM: the algorithm tries to place partial nodes (subgraph components) such that each predecessor of a node
v
is placed abovev
and each successor belowv
. - BOTTOM_TO_TOP: the algorithm tries to place partial nodes (subgraph components) such that each predecessor of a node
v
is placed belowv
and each successor abovev
. - LEFT_TO_RIGHT: the algorithm tries to place partial nodes (subgraph components) such that each predecessor of a node
v
is placed to the left ofv
and each successor to the right ofv
. - RIGHT_TO_LEFT: the algorithm tries to place partial nodes (subgraph components) such that each predecessor of a node
v
is placed to the right ofv
and each successor to the left ofv
.
Default Value
Property Value
See Also
Sample Graphs
Gets or sets the minimum distance between two adjacent nodes.
Remarks
Default Value
10
.Property Value
Throws
- Exception({ name: 'ArgumentError' })
- if the distance is negative
Sample Graphs
Gets or sets whether or not a postprocessing step should be applied to reduce the number of directed edges that do not comply with the specified layout orientation.
Default Value
true
.This postprocessing step is enabled.
Property Value
true
if this postprocessing step is applied, false
otherwiseSee Also
Gets or sets whether or not fixed (non-partial) group nodes may be resized.
Remarks
Default Value
false
.Fixed group nodes may not be resized.
Property Value
true
if fixed group nodes may be resized, false
otherwiseGets or sets whether or not edges between different subgraph components should be routed immediately.
Remarks
Default Value
false
.Edges are not routed immediately.
Property Value
true
if edges between different subgraph components are routed immediately, false
otherwise.See Also
Gets or sets the preferred time limit for the layout algorithm.
Remarks
Default Value
Throws
- Exception({ name: 'ArgumentError' })
- if the given duration is negative
Gets or sets the objective used for finding 'good' positions for subgraph components.
Default Value
BARYCENTER.Each subgraph component is placed close to the barycenter of its graph neighbors.
Property Value
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.
Implements
This method calculates the partial layout.
Remarks
- routeEdgesBetweenFixedElements
- applyLayout on the coreLayout for each subgraph component
- placeSubgraphs
- routeInterEdges
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the input graph
Implements
createLayoutData
(graph: LayoutGraph) : PartialLayoutData<LayoutNode,LayoutEdge,LayoutNodeLabel,LayoutEdgeLabel>Returns an instance of LayoutData<TNode,TEdge,TNodeLabel,TEdgeLabel> that can be used to perform item-specific configurations for the PartialLayout.
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
- ↪PartialLayoutData<LayoutNode,LayoutEdge,LayoutNodeLabel,LayoutEdgeLabel>
- an instance of layout data that can be used to perform item-specific configurations for the given PartialLayout.
Returns an instance of LayoutData<TNode,TEdge,TNodeLabel,TEdgeLabel> that can be used to perform item-specific configurations for the PartialLayout.
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
- ↪PartialLayoutData<INode,IEdge,ILabel,ILabel>
- an instance of layout data that can be used to perform item-specific configurations for the given PartialLayout.
LayoutExecutor
type is available at runtime.This method is called during the layout process and places the subgraph components one-by-one onto the drawing area.
Remarks
Therefore, it considers the specified objective for finding a suitable position.
Subclasses may implement a custom placement strategy or add some additional data. However, they must not modify the given subgraph component lists.
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the input graph
- subgraphComponents - IEnumerable<LayoutNode>[]
- each entry contains a collection with LayoutNodes that induces a subgraph component
This method is called during the layout process and routes all partial edges that connect two fixed elements.
Remarks
It either uses a custom edge router or an internal edge router that produces routes according to the specified routing style.
Subclasses may implement a custom routing style or add some additional data.
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the subgraph of the input graph induced by the fixed nodes
- partialEdges - IEnumerable<LayoutEdge>
- the list of partial edges to be routed
This method is called during the layout process and routes all inter-edges.
Remarks
Inter-edges are edges between different subgraph components including edges between fixed and partial elements. For the routing, this method uses the edge router instance set with method edgeRouter. If no edge router was specified by the user, it uses an internal edge router with routing style edgeRoutingStyle.
Subclasses may implement a custom routing style or add some additional data.
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the relevant subgraph
- interEdges - IEnumerable<LayoutEdge>
- the list of inter-edges to be routed
Constants
A data key for defining custom subgraph components.
Remarks
See Also
Sample Graphs
A data key for specifying the orientation of edges with respect to the main layout orientation.
Remarks
The orientation of an edge is 1
if it should be routed in the main layout direction, -1
if it should be routed against the main layout direction or 0
if it should be routed independently of the main layout direction.
The main layout orientation can be set using method layoutOrientation.
See Also
A data key for marking partial edges.
Remarks
true
are considered to be partial, those associated with value false
to be fixed.See Also
A data key for marking partial nodes.
Remarks
true
are considered to be partial, those associated with value false
to be fixed.