Class mxMedianHybridCrossingReduction
java.lang.Object
com.mxgraph.layout.hierarchical.stage.mxMedianHybridCrossingReduction
- All Implemented Interfaces:
mxHierarchicalLayoutStage
Performs a vertex ordering within ranks as described by Gansner et al 1993
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected class
A utility class used to track cells whilst sorting occurs on the median values. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected int
The total number of crossings found in the best configuration so farprotected int
protected mxHierarchicalLayout
Reference to the enclosing layout algorithmprotected int
The maximum number of iterations to perform whilst reducing edge crossingsprotected int
protected mxGraphAbstractHierarchyCell[][]
Stores each rank as a collection of cells in the best order found for each layer so far -
Constructor Summary
ConstructorsConstructorDescriptionConstructor that has the roots specified -
Method Summary
Modifier and TypeMethodDescriptionprivate int
Calculates the total number of edge crossing in the current graphprotected int
calculateRankCrossing
(int i, mxGraphHierarchyModel model) Calculates the number of edges crossings between the specified rank and the rank below itvoid
Performs a vertex ordering within ranks as described by Gansner et al 1993private void
medianRank
(int rankValue, boolean downwardSweep) Attempts to minimise the median placement of connected cells on this rank and one of the adjacent ranksprivate double
medianValue
(Collection<mxGraphAbstractHierarchyCell> connectedCells, int rankValue) Calculates the median rank order positioning for the specified cell using the connected cells on the specified rankprivate void
transpose
(int mainLoopIteration, mxGraphHierarchyModel model) Takes each possible adjacent cell pair on each rank and checks if swapping them around reduces the number of crossingprivate void
weightedMedian
(int iteration, mxGraphHierarchyModel model) Sweeps up or down the layout attempting to minimise the median placement of connected cells on adjacent ranks
-
Field Details
-
layout
Reference to the enclosing layout algorithm -
maxIterations
protected int maxIterationsThe maximum number of iterations to perform whilst reducing edge crossings -
nestedBestRanks
Stores each rank as a collection of cells in the best order found for each layer so far -
currentBestCrossings
protected int currentBestCrossingsThe total number of crossings found in the best configuration so far -
iterationsWithoutImprovement
protected int iterationsWithoutImprovement -
maxNoImprovementIterations
protected int maxNoImprovementIterations
-
-
Constructor Details
-
mxMedianHybridCrossingReduction
Constructor that has the roots specified
-
-
Method Details
-
execute
Performs a vertex ordering within ranks as described by Gansner et al 1993- Specified by:
execute
in interfacemxHierarchicalLayoutStage
-
calculateCrossings
Calculates the total number of edge crossing in the current graph- Parameters:
model
- the internal model describing the hierarchy- Returns:
- the current number of edge crossings in the hierarchy graph model in the current candidate layout
-
calculateRankCrossing
Calculates the number of edges crossings between the specified rank and the rank below it- Parameters:
i
- the topmost rank of the pair ( higher rank value )model
- the internal hierarchy model of the graph- Returns:
- the number of edges crossings with the rank beneath
-
transpose
Takes each possible adjacent cell pair on each rank and checks if swapping them around reduces the number of crossing- Parameters:
mainLoopIteration
- the iteration number of the main loopmodel
- the internal model describing the hierarchy
-
weightedMedian
Sweeps up or down the layout attempting to minimise the median placement of connected cells on adjacent ranks- Parameters:
iteration
- the iteration number of the main loopmodel
- the internal model describing the hierarchy
-
medianRank
private void medianRank(int rankValue, boolean downwardSweep) Attempts to minimise the median placement of connected cells on this rank and one of the adjacent ranks- Parameters:
rankValue
- the layer number of this rankdownwardSweep
- whether or not this is a downward sweep through the graph
-
medianValue
Calculates the median rank order positioning for the specified cell using the connected cells on the specified rank- Parameters:
connectedCells
- the cells on the specified rank connected to the specified cellrankValue
- the rank that the connected cell lie upon- Returns:
- the median rank ordering value of the connected cells
-