public class WeightedLayerer extends Object implements ILayerer
HierarchicLayout
(i.e., the assignment of the nodes to layers).
It first makes the directed graph acyclic. Then, it assigns the layers such that edge weights are respected. A weight defines a minimum distance between the two end points of an edge.
Modifier and Type | Field and Description |
---|---|
protected Object |
key
The key to access the
IDataProvider that holds the edge weights. |
protected IDataProvider |
weight
This is a
IDataProvider that holds for each Edge an integer value representing its weight. |
Constructor and Description |
---|
WeightedLayerer()
Creates an instance of
WeightedLayerer with the given key that provides access to the IDataProvider that
holds the edge weights and unlimited maximum duration for the WeightedLayerer . |
WeightedLayerer(Object key)
Creates an instance of
WeightedLayerer with the given key that provides access to the IDataProvider that
holds the edge weights and unlimited maximum duration for the WeightedLayerer . |
Modifier and Type | Method and Description |
---|---|
int |
assignLayers(Graph graph,
INodeMap layerID)
Assigns all nodes of the graph to layers.
|
void |
assignLayers(LayoutGraph graph,
ILayers layers,
ILayoutDataProvider ldp)
Assigns all nodes of the graph to layers and adds them to the
ILayers instance. |
int |
assignLayersFast(Graph graph,
INodeMap layerID)
Assigns all nodes of the graph to layers.
|
int |
assignNodeLayer(LayoutGraph graph,
INodeMap layerID,
EdgeList reversedEdges)
Assigns all nodes of the graph to layers.
|
int |
assignNodeLayer(LayoutGraph graph,
INodeMap layerID,
EdgeList reversedEdges,
IDataProvider weight)
Assigns all nodes of the graph to layers.
|
long |
getMaximumDuration()
Gets the time limit in milliseconds set for the layout algorithm.
|
protected double |
getWeight(Edge edge)
Returns the edge weight of the given edge using the weight based cycle removal heuristic.
|
boolean |
isWeightedCycleRemovalEnabled()
Gets whether or not the edges that need to be reversed are determined using an edge weight based heuristic or using a
depth first search based approach.
|
void |
makeDFSAcyclic(Graph graph,
EdgeList reversedEdges)
Removes cycles from the graph using a depth first search.
|
void |
setMaximumDuration(long value)
Sets the time limit in milliseconds set for the layout algorithm.
|
void |
setWeightedCycleRemovalEnabled(boolean value)
Sets whether or not the edges that need to be reversed are determined using an edge weight based heuristic or using a
depth first search based approach.
|
protected Object key
IDataProvider
that holds the edge weights.
More precisely, the corresponding IDataProvider
maps each edge of the input graph to an integer value
representing the edge's weight.
protected IDataProvider weight
IDataProvider
that holds for each Edge
an integer value representing its weight.public WeightedLayerer()
WeightedLayerer
with the given key that provides access to the IDataProvider
that
holds the edge weights and unlimited maximum duration for the WeightedLayerer
.public WeightedLayerer(Object key)
WeightedLayerer
with the given key that provides access to the IDataProvider
that
holds the edge weights and unlimited maximum duration for the WeightedLayerer
.key
- the key to access the IDataProvider
that holds the edge weightspublic int assignLayers(Graph graph, INodeMap layerID)
(v,w)
in E: layer(v) < layer(w)
graph
- the graph for which the layers are determinedlayerID
- the INodeMap
that will be filled by the layout algorithm and returns the zero-based index of the layer to which
each node belongspublic void assignLayers(LayoutGraph graph, ILayers layers, ILayoutDataProvider ldp)
ILayers
instance.assignLayers
in interface ILayerer
graph
- the input graphlayers
- the ILayers
instance that will be filled with the results of the calculationldp
- the ILayoutDataProvider
used for querying information about the nodes and edgesILayers.insert(com.yworks.yfiles.layout.hierarchic.LayerType, int)
,
ILayer.add(com.yworks.yfiles.algorithms.Node)
public int assignLayersFast(Graph graph, INodeMap layerID)
(v,w)
in E: layer(v) < layer(w)
graph
- the graph for which the layers are determinedlayerID
- the INodeMap
that will be filled by the layout algorithm and returns a zero-based layer index for each nodepublic int assignNodeLayer(LayoutGraph graph, INodeMap layerID, EdgeList reversedEdges)
(v,w)
in E: layer(v) < layer(w)
graph
- the graph for which the layers are determinedlayerID
- the INodeMap
that will be filled by the layout algorithm and returns the zero-based index of the layer to which
each node belongsreversedEdges
- an EdgeList
containing the edges which had been reversedpublic int assignNodeLayer(LayoutGraph graph, INodeMap layerID, EdgeList reversedEdges, IDataProvider weight)
(v,w)
in E: layer(v) < layer(w)
graph
- the graph for which the layers are determinedlayerID
- the INodeMap
that will be filled by the layout algorithm and returns a zero-based layer index for each nodereversedEdges
- an EdgeList
containing the edges which had been reversedweight
- the IDataProvider
that returns an integer value (weight) for each edgepublic long getMaximumDuration()
Values have to be greater than or equal to 0
.
IllegalArgumentException
- if the maximum duration is negativeLong.MAX_VALUE
. The layout algorithm runs unrestricted.setMaximumDuration(long)
protected double getWeight(Edge edge)
By default, all edges are considered to have weight 1.0
.
It may be overridden if non-uniform weights are desired.
edge
- given edgeisWeightedCycleRemovalEnabled()
,
setWeightedCycleRemovalEnabled(boolean)
public boolean isWeightedCycleRemovalEnabled()
The weight based approach may result in fewer reversed edges (especially for cases with many multi-edges) whereas the DFS based approach is likely to be faster.
false
. The DFS based approach is used.true
if an edge weight based heuristic is used; false
if a DFS based approach is usedsetWeightedCycleRemovalEnabled(boolean)
public void makeDFSAcyclic(Graph graph, EdgeList reversedEdges)
graph
- the graphreversedEdges
- an EdgeList
containing the edges which will be reversedpublic void setMaximumDuration(long value)
Values have to be greater than or equal to 0
.
IllegalArgumentException
- if the maximum duration is negativeLong.MAX_VALUE
. The layout algorithm runs unrestricted.value
- a non-negative value that specifies the time limitgetMaximumDuration()
public void setWeightedCycleRemovalEnabled(boolean value)
The weight based approach may result in fewer reversed edges (especially for cases with many multi-edges) whereas the DFS based approach is likely to be faster.
false
. The DFS based approach is used.value
- true
if an edge weight based heuristic is used; false
if a DFS based approach is usedisWeightedCycleRemovalEnabled()