Class KKLayoutAlgorithm<V>
- java.lang.Object
-
- org.jungrapht.visualization.layout.algorithms.AbstractLayoutAlgorithm<V>
-
- org.jungrapht.visualization.layout.algorithms.AbstractIterativeLayoutAlgorithm<V>
-
- org.jungrapht.visualization.layout.algorithms.KKLayoutAlgorithm<V>
-
- All Implemented Interfaces:
IterativeLayoutAlgorithm<V>,LayoutAlgorithm<V>,AfterRunnable,ExecutorConsumer,IterativeContext,Threaded
public class KKLayoutAlgorithm<V> extends AbstractIterativeLayoutAlgorithm<V> implements IterativeContext
Implements the Kamada-Kawai algorithm for vertex layout. Does not respect filter calls, and sometimes crashes when the view changes to it.- Author:
- Masanori Harada, Tom Nelson
- See Also:
- "Tomihisa Kamada and Satoru Kawai: An algorithm for drawing general indirect graphs. Information Processing Letters 31(1):7-15, 1989", "Tomihisa Kamada: On visualization of abstract objects and relations. Ph.D. dissertation, Dept. of Information Science, Univ. of Tokyo, Dec. 1988."
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classKKLayoutAlgorithm.Builder<V,T extends KKLayoutAlgorithm<V>,B extends KKLayoutAlgorithm.Builder<V,T,B>>static classKKLayoutAlgorithm.Pair<V>-
Nested classes/interfaces inherited from interface org.jungrapht.visualization.layout.algorithms.LayoutAlgorithm
LayoutAlgorithm.NoOp<V>
-
Nested classes/interfaces inherited from interface org.jungrapht.visualization.layout.algorithms.util.Threaded
Threaded.NoOp
-
-
Field Summary
Fields Modifier and Type Field Description protected doublediameterThe diameter of the visible graph.protected Map<KKLayoutAlgorithm.Pair<V>,Integer>distanceRetrieves graph distances between vertices of the visible graph-
Fields inherited from class org.jungrapht.visualization.layout.algorithms.AbstractIterativeLayoutAlgorithm
afterRunnable, cancelled, executor, layoutModel, preRelaxDurationMs, random, shouldPreRelax, threaded
-
Fields inherited from class org.jungrapht.visualization.layout.algorithms.AbstractLayoutAlgorithm
after
-
-
Constructor Summary
Constructors Modifier Constructor Description KKLayoutAlgorithm()protectedKKLayoutAlgorithm(KKLayoutAlgorithm.Builder<V,?,?> builder)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadjustForGravity()Shift all vertices so that the center of gravity is located at the center of the screen.static <V> KKLayoutAlgorithm.Builder<V,?,?>builder()booleandone()booleangetAdjustForGravity()booleangetExchangevertices()StringgetStatus()voidinitialize()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)voidstep()Advances one step.voidvisit(LayoutModel<V> layoutModel)because the IterativeLayoutAlgorithms use multithreading to continuously update vertex positions, the layoutModel state is saved (during the visit method) so that it can be used continuously-
Methods inherited from class org.jungrapht.visualization.layout.algorithms.AbstractIterativeLayoutAlgorithm
cancel, getExecutor, isThreaded, preRelax, setExecutor, setRandomSeed, setThreaded
-
Methods inherited from class org.jungrapht.visualization.layout.algorithms.AbstractLayoutAlgorithm
computeAverageVertexDimension, computeLayoutExtent, expandToFill, runAfter, setAfter
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jungrapht.visualization.layout.algorithms.util.AfterRunnable
runAfter, setAfter
-
Methods inherited from interface org.jungrapht.visualization.layout.algorithms.LayoutAlgorithm
constrained
-
-
-
-
Field Detail
-
distance
protected Map<KKLayoutAlgorithm.Pair<V>,Integer> distance
Retrieves graph distances between vertices of the visible graph
-
diameter
protected double diameter
The 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.
-
-
Constructor Detail
-
KKLayoutAlgorithm
public KKLayoutAlgorithm()
-
KKLayoutAlgorithm
protected KKLayoutAlgorithm(KKLayoutAlgorithm.Builder<V,?,?> builder)
-
-
Method Detail
-
builder
public static <V> KKLayoutAlgorithm.Builder<V,?,?> builder()
-
visit
public void visit(LayoutModel<V> layoutModel)
Description copied from class:AbstractIterativeLayoutAlgorithmbecause the IterativeLayoutAlgorithms use multithreading to continuously update vertex positions, the layoutModel state is saved (during the visit method) so that it can be used continuously- Specified by:
visitin interfaceLayoutAlgorithm<V>- Overrides:
visitin classAbstractIterativeLayoutAlgorithm<V>- Parameters:
layoutModel- the mediator between the container for vertices (the Graph) and the mapping from Vertex to Point
-
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
public String getStatus()
- Returns:
- a string with information about the current status of the algorithm.
-
setMaxIterations
public void setMaxIterations(int maxIterations)
-
done
public boolean done()
- Specified by:
donein interfaceIterativeContext- Returns:
- true if the current iteration has passed the maximum count.
-
initialize
public void initialize()
-
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.
-
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()
-
-