Class KKLayout<V,E>
java.lang.Object
edu.uci.ics.jung.algorithms.layout.AbstractLayout<V,E>
edu.uci.ics.jung.algorithms.layout.KKLayout<V,E>
- All Implemented Interfaces:
com.google.common.base.Function<V,Point2D>, Layout<V, E>, IterativeContext, Function<V, Point2D>
Implements the Kamada-Kawai algorithm for node layout.
Does not respect filter calls, and sometimes crashes when the view changes to it.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprivate intprotected doubleThe diameter of the visible graph.private doubleA multiplicative factor which specifies the fraction of the graph's diameter to be used as the inter-vertex distance between disconnected vertices.Retrieves graph distances between vertices of the visible graphprivate double[][]private doubleprivate booleanprivate doubleprivate doubleprivate doubleA multiplicative factor which partly specifies the "preferred" length of an edge (L).private intprivate Stringprivate V[]private Point2D[]Fields inherited from class AbstractLayout
graph, initialized, locations, size -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidShift all vertices so that the center of gravity is located at the center of the screen.private doublecalcDeltaM(int m) Calculates the gradient of energy function at the vertex m.private double[]calcDeltaXY(int m) Determines a step to new position of the vertex m.private doubleCalculates the energy function E.private doublecalcEnergyIfExchanged(int p, int q) Calculates the energy function E as if positions of the specified vertices are exchanged.booleandone()booleanbooleanvoidInitializes fields in the node that may not have been set during the constructor.booleanvoidreset()voidsetAdjustForGravity(boolean on) voidsetDisconnectedDistanceMultiplier(double disconnected_multiplier) voidsetExchangeVertices(boolean on) Enable or disable the local minimum escape technique by exchanging vertices.voidsetLengthFactor(double length_factor) voidsetMaxIterations(int maxIterations) voidWhen a visualization is resized, it presumably wants to fix the locations of the vertices and possibly to reinitialize its data.voidstep()Advances one step.Methods inherited from class AbstractLayout
apply, getGraph, getSize, getX, getY, isLocked, lock, lock, offsetVertex, setGraph, setInitializer, setLocation, setLocationMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.google.common.base.Function
equals
-
Field Details
-
EPSILON
private double EPSILON -
currentIteration
private int currentIteration -
maxIterations
private int maxIterations -
status
-
L
private double L -
K
private double K -
dm
private double[][] dm -
adjustForGravity
private boolean adjustForGravity -
exchangeVertices
private boolean exchangeVertices -
vertices
-
xydata
-
distance
-
diameter
protected double diameterThe diameter of the visible graph. In other words, the maximum over all pairs of vertices of the length of the shortest path between a and bf the visible graph. -
length_factor
private double length_factorA multiplicative factor which partly specifies the "preferred" length of an edge (L). -
disconnected_multiplier
private double disconnected_multiplierA multiplicative factor which specifies the fraction of the graph's diameter to be used as the inter-vertex distance between disconnected vertices.
-
-
Constructor Details
-
KKLayout
-
KKLayout
-
-
Method Details
-
setLengthFactor
public void setLengthFactor(double length_factor) - Parameters:
length_factor- a multiplicative factor which partially specifies the preferred length of an edge
-
setDisconnectedDistanceMultiplier
public void setDisconnectedDistanceMultiplier(double disconnected_multiplier) - Parameters:
disconnected_multiplier- a multiplicative factor that specifies the fraction of the graph's diameter to be used as the inter-vertex distance between disconnected vertices
-
getStatus
- Returns:
- a string with information about the current status of the algorithm.
-
setMaxIterations
public void setMaxIterations(int maxIterations) -
isIncremental
public boolean isIncremental()- Returns:
- true
-
done
public boolean done()- Specified by:
donein interfaceIterativeContext- Returns:
- true if the current iteration has passed the maximum count.
-
initialize
public void initialize()Description copied from interface:LayoutInitializes fields in the node that may not have been set during the constructor. Must be called before the iterations begin.- Specified by:
initializein interfaceLayout<V,E>
-
step
public void step()Description copied from interface:IterativeContextAdvances one step.- Specified by:
stepin interfaceIterativeContext
-
adjustForGravity
public void adjustForGravity()Shift all vertices so that the center of gravity is located at the center of the screen. -
setSize
Description copied from class:AbstractLayoutWhen a visualization is resized, it presumably wants to fix the locations of the vertices and possibly to reinitialize its data. The current method calls initializeLocations followed by initialize_local. -
setAdjustForGravity
public void setAdjustForGravity(boolean on) -
getAdjustForGravity
public boolean getAdjustForGravity() -
setExchangeVertices
public void setExchangeVertices(boolean on) Enable or disable the local minimum escape technique by exchanging vertices.- Parameters:
on- iff the local minimum escape technique is to be enabled
-
getExchangeVertices
public boolean getExchangeVertices() -
calcDeltaXY
private double[] calcDeltaXY(int m) Determines a step to new position of the vertex m. -
calcDeltaM
private double calcDeltaM(int m) Calculates the gradient of energy function at the vertex m. -
calcEnergy
private double calcEnergy()Calculates the energy function E. -
calcEnergyIfExchanged
private double calcEnergyIfExchanged(int p, int q) Calculates the energy function E as if positions of the specified vertices are exchanged. -
reset
-