Class FRLayoutAlgorithm<V>
- java.lang.Object
-
- org.jungrapht.visualization.layout.algorithms.AbstractLayoutAlgorithm<V>
-
- org.jungrapht.visualization.layout.algorithms.AbstractIterativeLayoutAlgorithm<V>
-
- org.jungrapht.visualization.layout.algorithms.FRLayoutAlgorithm<V>
-
- All Implemented Interfaces:
IterativeLayoutAlgorithm<V>,LayoutAlgorithm<V>,AfterRunnable,ExecutorConsumer,IterativeContext,Threaded
public class FRLayoutAlgorithm<V> extends AbstractIterativeLayoutAlgorithm<V> implements IterativeContext
Implements the Fruchterman-Reingold force-directed algorithm for vertex 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
- Author:
- Scott White, Yan-Biao Boey, Danyel Fisher, Tom Nelson
- 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 static classFRLayoutAlgorithm.Builder<V,T extends FRLayoutAlgorithm<V>,B extends FRLayoutAlgorithm.Builder<V,T,B>>-
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 doubleattractionConstantprotected doubleEPSILONprotected Map<V,Point>frVertexDataprotected Function<V,Point>initializerprotected doublerepulsionConstantprotected StandardFRRepulsionrepulsionContractprotected StandardFRRepulsion.BuilderrepulsionContractBuilder-
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 FRLayoutAlgorithm()protectedFRLayoutAlgorithm(FRLayoutAlgorithm.Builder<V,?,?> builder)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <V> FRLayoutAlgorithm.Builder<V,?,?>builder()protected voidcalcAttraction(Object edge)protected voidcalcPositions(V vertex)booleandone()protected PointgetFRData(V vertex)voidinitialize()voidsetAttractionMultiplier(double attraction)voidsetMaxIterations(int maxIterations)voidsetRepulsionMultiplier(double repulsion)voidstep()Moves the iteration forward one notch, calculation attraction and repulsion between vertices and edges and cooling the temperature.StringtoString()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, 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
-
attractionConstant
protected double attractionConstant
-
repulsionConstant
protected double repulsionConstant
-
repulsionContractBuilder
protected StandardFRRepulsion.Builder repulsionContractBuilder
-
repulsionContract
protected StandardFRRepulsion repulsionContract
-
EPSILON
protected double EPSILON
-
-
Constructor Detail
-
FRLayoutAlgorithm
public FRLayoutAlgorithm()
-
FRLayoutAlgorithm
protected FRLayoutAlgorithm(FRLayoutAlgorithm.Builder<V,?,?> builder)
-
-
Method Detail
-
builder
public static <V> FRLayoutAlgorithm.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
-
setAttractionMultiplier
public void setAttractionMultiplier(double attraction)
-
setRepulsionMultiplier
public void setRepulsionMultiplier(double repulsion)
-
initialize
public void initialize()
-
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 vertex)
-
calcAttraction
protected void calcAttraction(Object edge)
-
setMaxIterations
public void setMaxIterations(int maxIterations)
-
done
public boolean done()
- Specified by:
donein interfaceIterativeContext- Returns:
- true once the current iteration has passed the maximum count.
-
-