Class FRLayout<V,E>
- java.lang.Object
-
- edu.uci.ics.jung.algorithms.layout.AbstractLayout<V,E>
-
- edu.uci.ics.jung.algorithms.layout.FRLayout<V,E>
-
- All Implemented Interfaces:
com.google.common.base.Function<V,java.awt.geom.Point2D>,Layout<V,E>,IterativeContext,java.util.function.Function<V,java.awt.geom.Point2D>
public class FRLayout<V,E> extends AbstractLayout<V,E> implements IterativeContext
Implements the Fruchterman-Reingold force-directed algorithm for node layout.Behavior is determined by the following settable parameters:
- attraction multiplier: how much edges try to keep their vertices together
- repulsion multiplier: how much vertices try to push each other apart
- maximum iterations: how many iterations this algorithm will use before stopping
- See Also:
- "Fruchterman and Reingold, 'Graph Drawing by Force-directed Placement'", "http://i11www.ilkd.uni-karlsruhe.de/teaching/SS_04/visualisierung/papers/fruchterman91graph.pdf"
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classFRLayout.FRVertexData
-
Field Summary
Fields Modifier and Type Field Description private doubleattraction_constantprivate doubleattraction_multiplierprivate intcurrentIterationprivate doubleEPSILONprivate doubleforceConstantprotected com.google.common.cache.LoadingCache<V,FRLayout.FRVertexData>frVertexDataprivate doublemax_dimensionprivate intmMaxIterationsprivate doublerepulsion_constantprivate doublerepulsion_multiplierprivate doubletemperature-
Fields inherited from class edu.uci.ics.jung.algorithms.layout.AbstractLayout
graph, initialized, locations, size
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcalcAttraction(E e)protected voidcalcPositions(V v)protected voidcalcRepulsion(V v1)private voidcool()private voiddoInit()booleandone()protected FRLayout.FRVertexDatagetFRData(V v)voidinitialize()Initializes fields in the node that may not have been set during the constructor.booleanisIncremental()voidreset()voidsetAttractionMultiplier(double attraction)voidsetMaxIterations(int maxIterations)voidsetRepulsionMultiplier(double repulsion)voidsetSize(java.awt.Dimension size)When a visualization is resized, it presumably wants to fix the locations of the vertices and possibly to reinitialize its data.voidstep()Moves the iteration forward one notch, calculation attraction and repulsion between vertices and edges and cooling the temperature.-
Methods inherited from class edu.uci.ics.jung.algorithms.layout.AbstractLayout
apply, getGraph, getSize, getX, getY, isLocked, lock, lock, offsetVertex, setGraph, setInitializer, setLocation, setLocation
-
-
-
-
Field Detail
-
forceConstant
private double forceConstant
-
temperature
private double temperature
-
currentIteration
private int currentIteration
-
mMaxIterations
private int mMaxIterations
-
frVertexData
protected com.google.common.cache.LoadingCache<V,FRLayout.FRVertexData> frVertexData
-
attraction_multiplier
private double attraction_multiplier
-
attraction_constant
private double attraction_constant
-
repulsion_multiplier
private double repulsion_multiplier
-
repulsion_constant
private double repulsion_constant
-
max_dimension
private double max_dimension
-
EPSILON
private double EPSILON
-
-
Method Detail
-
setSize
public void setSize(java.awt.Dimension size)
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.
-
setAttractionMultiplier
public void setAttractionMultiplier(double attraction)
-
setRepulsionMultiplier
public void setRepulsionMultiplier(double repulsion)
-
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>
-
doInit
private void doInit()
-
step
public void step()
Moves the iteration forward one notch, calculation attraction and repulsion between vertices and edges and cooling the temperature.- Specified by:
stepin interfaceIterativeContext
-
calcPositions
protected void calcPositions(V v)
-
calcAttraction
protected void calcAttraction(E e)
-
calcRepulsion
protected void calcRepulsion(V v1)
-
cool
private void cool()
-
setMaxIterations
public void setMaxIterations(int maxIterations)
-
getFRData
protected FRLayout.FRVertexData getFRData(V v)
-
isIncremental
public boolean isIncremental()
- Returns:
- true
-
done
public boolean done()
- Specified by:
donein interfaceIterativeContext- Returns:
- true once the current iteration has passed the maximum count.
-
-