Search this API

y.layout.hierarchic
Class ClassicLayerSequencer

java.lang.Object
  extended by y.layout.hierarchic.ClassicLayerSequencer
All Implemented Interfaces:
LayerSequencer

public class ClassicLayerSequencer
extends Object
implements LayerSequencer

This class implements the second phase of the Sugiyama algorithm. It minimizes the crossings in the diagram by using either the barycentric or median heuristic.


Field Summary
static byte BARYCENTER_HEURISTIC
          Weight assignment heuristic specifier.
static Object GROUP_KEY
          This is the key, which must be used to register the DataProvider which contains the mappings between nodes and group ids.
static byte MEDIAN_HEURISTIC
          Weight assignment heuristic specifier.
 
Constructor Summary
ClassicLayerSequencer()
          Instantiates a new layer sequencer.
 
Method Summary
 void adoptValues(LayerSequencer otherSequencer)
          Tries to adopt/copy the settings of the given LayerSequencer to this sequencer.
 NodeList[] getLayers(LayoutGraph g, NodeMap layerMap, int maxLayer)
          Calculates the sequence of nodes within each layer.
 long getMaximalDuration()
          Returns the proposed maximal duration for the calculation of the sequence.
 int getRandomizationRounds()
          Returns the number of randomized rounds this algorithm will try if there was no optimal solution.
 int getRecentCrossingNumber()
          Returns the number of edge crossings that were produced by this sequencer the last time it was applied to a graph.
 boolean getRemoveFalseCrossings()
          Returns whether or not to remove false crossings.
 boolean getUseTransposition()
          Returns whether or not the transposition heuristic should be used.
 byte getWeightHeuristic()
          Returns the currently set weight heuristic.
 boolean isUsingGroups()
          Returns whether or not the layerer will preserve the groupings of nodes between each layer.
 void setMaximalDuration(long msec)
          Sets the maximum amount of time granted for this sequencer per execution.
 void setRandomizationRounds(int randomizationRounds)
          Sets the number of additional rounds the algorithm will restart with randomized solutions as long as there might be a better solution to the current best.
 void setRemoveFalseCrossings(boolean b)
          Specifies whether or not to remove so-called false crossings in an additional phase.
 void setUseTransposition(boolean b)
          Specifies whether or not an additional crossing minimization heuristic should be used.
 void setUsingGroups(boolean usingGroups)
          Specifies whether or not the layerer will preserve the groupings of nodes between each layer.
 void setWeightHeuristic(byte h)
          Sets the weight heuristic to be used.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GROUP_KEY

public static final Object GROUP_KEY
This is the key, which must be used to register the DataProvider which contains the mappings between nodes and group ids. Group ids are integer objects, containing unique group numbers or null, if the node belongs to no specific group.


BARYCENTER_HEURISTIC

public static final byte BARYCENTER_HEURISTIC
Weight assignment heuristic specifier. A node position within a layer will be determined by the barycenter of its successor (downward pass) and predecessor (upward pass) nodes.

See Also:
Constant Field Values

MEDIAN_HEURISTIC

public static final byte MEDIAN_HEURISTIC
Weight assignment heuristic specifier. A node position within a layer will be determined by the median position of its successor (downward pass) and predecessor (upward pass) nodes.

See Also:
Constant Field Values
Constructor Detail

ClassicLayerSequencer

public ClassicLayerSequencer()
Instantiates a new layer sequencer.

Method Detail

setUseTransposition

public void setUseTransposition(boolean b)
Specifies whether or not an additional crossing minimization heuristic should be used. Activating this heuristic can reduce the overall number of edge crossings. On the other hand its activation increases running time.

By default the transposition rule is active.


getUseTransposition

public boolean getUseTransposition()
Returns whether or not the transposition heuristic should be used.

See Also:
setUseTransposition(boolean)

setWeightHeuristic

public void setWeightHeuristic(byte h)
Sets the weight heuristic to be used. By default BARYCENTER_HEURISTIC is set.

Parameters:
h - one of BARYCENTER_HEURISTIC and MEDIAN_HEURISTIC.

getWeightHeuristic

public byte getWeightHeuristic()
Returns the currently set weight heuristic.

See Also:
setWeightHeuristic(byte)

setRemoveFalseCrossings

public void setRemoveFalseCrossings(boolean b)
Specifies whether or not to remove so-called false crossings in an additional phase. A false crossing is a crossing between two edges that share a common terminal node.

By default this feature is active.


getRemoveFalseCrossings

public boolean getRemoveFalseCrossings()
Returns whether or not to remove false crossings.

See Also:
setRemoveFalseCrossings(boolean)

setMaximalDuration

public void setMaximalDuration(long msec)
Sets the maximum amount of time granted for this sequencer per execution.

Parameters:
msec - granted time in milliseconds

getRecentCrossingNumber

public int getRecentCrossingNumber()
Returns the number of edge crossings that were produced by this sequencer the last time it was applied to a graph.

Precondition:
Method getLayers(LayoutGraph, NodeMap, int) must have been called before.

adoptValues

public void adoptValues(LayerSequencer otherSequencer)
Tries to adopt/copy the settings of the given LayerSequencer to this sequencer.


getLayers

public NodeList[] getLayers(LayoutGraph g,
                            NodeMap layerMap,
                            int maxLayer)
Description copied from interface: LayerSequencer
Calculates the sequence of nodes within each layer.

Specified by:
getLayers in interface LayerSequencer
Parameters:
g - the graph being acted upon
layerMap - provides for each node an integral number signifying the layer of that node. The first layer has the number 0.
maxLayer - the number of different layers
Returns:
an array of length maxLayer containing node lists. Each node list contains the nodes of a corresponding layer. The order of the nodes within each node list represents the sequence of the nodes within their layer.

isUsingGroups

public boolean isUsingGroups()
Returns whether or not the layerer will preserve the groupings of nodes between each layer. Preserving groupings means nodes having the same integer group number will be placed directly next to each other within each layer.

Defaults to false.


setUsingGroups

public void setUsingGroups(boolean usingGroups)
Specifies whether or not the layerer will preserve the groupings of nodes between each layer. Preserving groupings means nodes having the same integer group number will be placed directly next to each other within each layer.

Defaults to false.


getMaximalDuration

public long getMaximalDuration()
Returns the proposed maximal duration for the calculation of the sequence.


getRandomizationRounds

public int getRandomizationRounds()
Returns the number of randomized rounds this algorithm will try if there was no optimal solution.

Returns:
the number of rounds. Default is 40.

setRandomizationRounds

public void setRandomizationRounds(int randomizationRounds)
Sets the number of additional rounds the algorithm will restart with randomized solutions as long as there might be a better solution to the current best.

Parameters:
randomizationRounds - the new number of additional rounds

© Copyright 2000-2013,
yWorks GmbH.
All rights reserved.