y.layout.hierarchic
Class ClassicLayerSequencer

java.lang.Object
  |
  +--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, 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()
          Getter for property usingGroups.
 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)
          Whether or not to remove so-called false crossings in an additional phase.
 void setUseTransposition(boolean b)
          Whether or not an additional crossing minimization heuristic should be used.
 void setUsingGroups(boolean usingGroups)
          Setter for property usingGroups.
 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)
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:
ClassicLayerSequencer.setUseTransposition(boolean)

setWeightHeuristic

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

Parameters:
h - one of ClassicLayerSequencer.BARYCENTER_HEURISTIC and ClassicLayerSequencer.MEDIAN_HEURISTIC.

getWeightHeuristic

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

See Also:
ClassicLayerSequencer.setWeightHeuristic(byte)

setRemoveFalseCrossings

public void setRemoveFalseCrossings(boolean b)
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:
ClassicLayerSequencer.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 ClassicLayerSequencer.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 diferent layers
Returns:
an array of length maxLayer containing nodelists. Each nodelist contains the nodes of a corrsponding layer. The order of the nodes within each nodelist represents the sequence of the nodes within their layer.

isUsingGroups

public boolean isUsingGroups()
Getter for property usingGroups. If set to true, the layerer will preserve the groupings of nodes between each layer, i.e. nodes having the same integer group number will be placed directly next to each other within each layer default value is false

Returns:
Value of property usingGroups.

setUsingGroups

public void setUsingGroups(boolean usingGroups)
Setter for property usingGroups. If set to true, the layerer will preserve the groupings of nodes between each layer, i.e. nodes having the same integer group number will be placed directly next to each other within each layer

Parameters:
usingGroups - New value of property usingGroups.

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-2003,
yWorks GmbH.
All rights reserved.

2003