Search this API

y.layout.hierarchic
Class TopologicalLayerer

java.lang.Object
  extended by y.layout.hierarchic.TopologicalLayerer
All Implemented Interfaces:
Layerer

public class TopologicalLayerer
extends java.lang.Object
implements Layerer, Layerer

This class implements the layering phase of the IncrementalHierarchicLayouter (i.e., assignment of the nodes to layers).

It uses topological sorting to assign layers to the nodes.

 
This class can be used with IncrementalHierarchicLayouter as well as HierarchicLayouter and HierarchicGroupLayouter.
 

Field Summary
static byte DOWN_SHIFT
          A ranking policy that specifies that nodes are re-ranked by an inexpensive downshift rule.
static byte NO_RERANKING
          A ranking policy that specifies that nodes are not re-ranked after the initial topological layering step.
static byte TIGHT_TREE
          A ranking policy that specifies that nodes are re-ranked by finding a spanning tree that contains only tight (length 1) edges.
 
Constructor Summary
TopologicalLayerer()
          Creates a new instance of TopologicalLayerer with default settings.
 
Method Summary
 void assignLayers(LayoutGraph graph, Layers layers, LayoutDataProvider ldp)
          Assigns all nodes of the graph to layers and adds them to the Layers instance.
 int assignNodeLayer(LayoutGraph graph, NodeMap layerID, EdgeList reversedEdges)
          This method assigns the nodes in the graph to layers.
 byte getRankingPolicy()
          Returns the (re-)ranking policy used by this TopologicalLayerer instance.
 void setRankingPolicy(byte p)
          Specifies the (re-)ranking policy used by this TopologicalLayerer instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_RERANKING

public static final byte NO_RERANKING
A ranking policy that specifies that nodes are not re-ranked after the initial topological layering step.

See Also:
Constant Field Values
Sample Graph:

DOWN_SHIFT

public static final byte DOWN_SHIFT
A ranking policy that specifies that nodes are re-ranked by an inexpensive downshift rule.

See Also:
Constant Field Values
Sample Graph:

TIGHT_TREE

public static final byte TIGHT_TREE
A ranking policy that specifies that nodes are re-ranked by finding a spanning tree that contains only tight (length 1) edges.

See Also:
Constant Field Values
Sample Graph:
Constructor Detail

TopologicalLayerer

public TopologicalLayerer()
Creates a new instance of TopologicalLayerer with default settings.

Method Detail

setRankingPolicy

public void setRankingPolicy(byte p)
Specifies the (re-)ranking policy used by this TopologicalLayerer instance.

Default Value:
The default value is NO_RERANKING
Parameters:
p - one of the predefined ranking policies
Throws:
java.lang.IllegalArgumentException - if an unknown ranking policy is given

getRankingPolicy

public byte getRankingPolicy()
Returns the (re-)ranking policy used by this TopologicalLayerer instance.

Returns:
one of the predefined ranking policies
See Also:
setRankingPolicy(byte)

assignNodeLayer

public int assignNodeLayer(LayoutGraph graph,
                           NodeMap layerID,
                           EdgeList reversedEdges)
This method assigns the nodes in the graph to layers.

Postcondition:
For all (v,w) in E: layer(v) < layer(w)
Parameters:
graph - the given graph
layerID - the NodeMap that will be filled by the layout algorithm and returns the zero-based index of the layer to which each node belongs
reversedEdges - an EdgeList containing the edges which had been reversed
Returns:
the number of layers

assignLayers

public void assignLayers(LayoutGraph graph,
                         Layers layers,
                         LayoutDataProvider ldp)
Assigns all nodes of the graph to layers and adds them to the Layers instance.

Specified by:
assignLayers in interface Layerer
Parameters:
graph - the input graph
layers - the Layers instance that will be filled with the results of the calculation
ldp - the LayoutDataProvider used for querying information about the nodes and edges
See Also:
Layers.insert(byte, int), Layer.add(y.base.Node)

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