This class is an implementation of the IPortConstraintOptimizer interface that tries to assign the edges of the graph to ports considering the specified PortCandidates.
Remarks
Instances of this class can be set using property portConstraintOptimizer.
This implementation will query for IDataProviders registered with the graph with keys SOURCE_PORT_CANDIDATE_COLLECTION_DP_KEY, TARGET_PORT_CANDIDATE_COLLECTION_DP_KEY and NODE_PORT_CANDIDATE_SET_DP_KEY. It will try to assign each edge one of the matching PortCandidates without introducing too many crossings and without violating the cost or capacity constraints.
Default Values of Properties
backLoopPenalty | 1.0 | |
crossingPenalty | 10.0d | |
deterministic | true | A deterministic algorithm will be applied. |
overUsagePenalty | 100.0d |
Type Details
- yfiles module
- layout-hierarchic
- yfiles-umd modules
- layout-familytree, layout-hierarchic, layout-radial, layout
- Legacy UMD name
- yfiles.hierarchic.PortCandidateOptimizer
See Also
Constructors
Creates a new instance of PortCandidateOptimizer with the default settings.
Parameters
A map of options to pass to the method.
- deterministic - boolean
Whether or not this implementation uses a deterministic algorithm to assign the PortCandidates. This option sets the deterministic property on the created object.
- backLoopPenalty - number
The penalty cost associated with each back-loop. This option sets the backLoopPenalty property on the created object.
- crossingPenalty - number
The penalty cost associated with a crossing that would occur if a given combination of PortCandidates would be chosen. This option sets the crossingPenalty property on the created object.
- overUsagePenalty - number
The penalty cost associated with each edge being assigned to a port which has already reached its capacity. This option sets the overUsagePenalty property on the created object.
- mirrorMode - MirrorModes
The mirror mask that defines which orientations should be mirrored. This option sets the mirrorMode property on the created object.
- layoutOrientation - LayoutOrientation
The layout orientation. This option sets the layoutOrientation property on the created object.
Properties
Gets or sets the penalty cost associated with each back-loop.
Remarks
Default Value
1.0
.Throws
- Exception({ name: 'ArgumentError' })
- if the penalty cost is negative
Gets or sets the penalty cost associated with a crossing that would occur if a given combination of PortCandidates would be chosen.
Remarks
Default Value
10.0d
.Throws
- Exception({ name: 'ArgumentError' })
- if the crossing penalty is negative
Gets or sets whether or not this implementation uses a deterministic algorithm to assign the PortCandidates.
Default Value
true
.A deterministic algorithm will be applied.
Gets or sets the layout orientation.
Remarks
Default Value
See Also
Defined in
Gets or sets the mirror mask that defines which orientations should be mirrored.
Remarks
90
, 180
or 270
degrees. Afterwards, the graph can be mirrored at the x-axis (for horizontal layout orientations) or y-axis (for vertical layout orientations). Which directions are mirrored can be defined by the given mask.Default Value
See Also
Defined in
Gets or sets the penalty cost associated with each edge being assigned to a port which has already reached its capacity.
Remarks
Default Value
100.0d
.Throws
- Exception({ name: 'ArgumentError' })
- if the penalty cost is negative
See Also
Methods
Returns the data provider that provides the port candidate sets for nodes.
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- The graph that stores the data provider
insertSameLayerStructures
(graph: LayoutGraph, layers: ILayers, ldp: ILayoutDataProvider, itemFactory: IItemFactory) : PortConstraintOptimizerSameLayerDataInserts a same-layer edge structure for each same-layer edge of the original graph.
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the input graph
- layers - ILayers
- the given ILayers instance holding the layering information
- ldp - ILayoutDataProvider
- the ILayoutDataProvider implementation which provides access to the INodeData and IEdgeData instances
- itemFactory - IItemFactory
- the factory that sets the temporary port constraints
See Also
Overrides
optimizeAfterLayering
(graph: LayoutGraph, layers: ILayers, ldp: ILayoutDataProvider, itemFactory: IItemFactory)Assigns new temporary port constraints after the nodes have been assigned to layers.
Remarks
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the input graph
- layers - ILayers
- the given ILayers instance holding the layering information
- ldp - ILayoutDataProvider
- the ILayoutDataProvider implementation which provides access to the INodeData and IEdgeData instances
- itemFactory - IItemFactory
- the factory that sets the temporary port constraints
See Also
Implements
optimizeAfterSequencing
(graph: LayoutGraph, layers: ILayers, ldp: ILayoutDataProvider, itemFactory: IItemFactory)Assigns new temporary port constraints after the order of the nodes in each layer has been determined.
Remarks
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the input graph
- layers - ILayers
- the given ILayers instance holding the layering information
- ldp - ILayoutDataProvider
- the ILayoutDataProvider implementation which provides access to the INodeData and IEdgeData instances
- itemFactory - IItemFactory
- the factory that sets the temporary port constraints
See Also
Overrides
optimizeAfterSequencingForAllNodes
(inEdgeOrder: IComparer<Object>, outEdgeOrder: IComparer<Object>, graph: LayoutGraph, layers: ILayers, ldp: ILayoutDataProvider, itemFactory: IItemFactory)Assigns new temporary port constraints after the order of the nodes in each layer has been determined.
Remarks
More precisely, it is called after the sequence of the nodes has been determined. It invokes optimizeAfterSequencingForSingleNode for every node of the original layout graph and omits the nodes of the same-layer structures.
Incoming and outgoing edges are sorted using IComparer<T> instances which define the preferred ordering of the incoming and outgoing edges from left to right.
Parameters
A map of options to pass to the method.
- inEdgeOrder - IComparer<Object>
- a given IComparer<T> instance for incoming edges
- outEdgeOrder - IComparer<Object>
- a given IComparer<T> instance for outgoing edges
- graph - LayoutGraph
- the input graph
- layers - ILayers
- ldp - ILayoutDataProvider
- the ILayoutDataProvider implementation which provides access to the INodeData and IEdgeData instances
- itemFactory - IItemFactory
- the factory that sets the temporary port constraints
See Also
Defined in
optimizeAfterSequencingForSingleNode
(node: YNode, inEdgeOrder: IComparer<Object>, outEdgeOrder: IComparer<Object>, graph: LayoutGraph, ldp: ILayoutDataProvider, itemFactory: IItemFactory)Assigns new temporary port constraints to a given node of the graph after the order of the nodes in each layer has been determined.
Remarks
More precisely, it is called after the sequence of the nodes has been determined.
Incoming and outgoing edges are sorted using IComparer<T> instances which define the preferred ordering of the incoming and outgoing edges from left to right.
Parameters
A map of options to pass to the method.
- node - YNode
- the original node to set temporary port constraints
- inEdgeOrder - IComparer<Object>
- a given IComparer<T> instance for incoming edges
- outEdgeOrder - IComparer<Object>
- a given IComparer<T> instance for outgoing edges
- graph - LayoutGraph
- the input graph
- ldp - ILayoutDataProvider
- the ILayoutDataProvider implementation which provides access to the INodeData and IEdgeData instances
- itemFactory - IItemFactory
- the factory that sets the temporary port constraints
See Also
Implements
removeSameLayerStructures
(sameLayerData: PortConstraintOptimizerSameLayerData, graph: LayoutGraph, ldp: ILayoutDataProvider, itemFactory: IItemFactory)Removes the same-layer edge structure created using insertSameLayerStructures.
Parameters
A map of options to pass to the method.
- sameLayerData - PortConstraintOptimizerSameLayerData
- a given PortConstraintOptimizerSameLayerData instance holding the information about the same-layer structures.
- graph - LayoutGraph
- the input graph
- ldp - ILayoutDataProvider
- the ILayoutDataProvider implementation which provides access to the INodeData and IEdgeData instances
- itemFactory - IItemFactory
- the factory that sets the temporary port constraints