java.lang.Object
org.jgrapht.alg.drawing.FRLayoutAlgorithm2D<V,E>
- Type Parameters:
V
- the vertex typeE
- the edge type
- All Implemented Interfaces:
LayoutAlgorithm2D<V,
E>
- Direct Known Subclasses:
IndexedFRLayoutAlgorithm2D
Fruchterman and Reingold Force-Directed Placement Algorithm.
The algorithm belongs in the broad category of
force directed graph
drawing algorithms and is described in the paper:
- Thomas M. J. Fruchterman and Edward M. Reingold. Graph drawing by force-directed placement. Software: Practice and experience, 21(11):1129--1164, 1991.
- Author:
- Dimitrios Michail
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected class
An inverse linear temperature model.static interface
A general interface for a temperature model. -
Field Summary
Modifier and TypeFieldDescriptionprotected final ToleranceDoubleComparator
static final int
Default number of iterationsstatic final double
Default normalization factor when calculating optimal distanceA model initializerprotected int
protected double
protected double
protected Random
-
Constructor Summary
ConstructorDescriptionCreate a new layout algorithmFRLayoutAlgorithm2D
(int iterations) Create a new layout algorithmFRLayoutAlgorithm2D
(int iterations, double normalizationFactor) Create a new layout algorithmFRLayoutAlgorithm2D
(int iterations, double normalizationFactor, BiFunction<LayoutModel2D<V>, Integer, FRLayoutAlgorithm2D.TemperatureModel> temperatureModelSupplier, Random rng) Create a new layout algorithmFRLayoutAlgorithm2D
(int iterations, double normalizationFactor, BiFunction<LayoutModel2D<V>, Integer, FRLayoutAlgorithm2D.TemperatureModel> temperatureModelSupplier, Random rng, double tolerance) Create a new layout algorithmFRLayoutAlgorithm2D
(int iterations, double normalizationFactor, Random rng) Create a new layout algorithmFRLayoutAlgorithm2D
(int iterations, double normalizationFactor, Random rng, double tolerance) Create a new layout algorithm -
Method Summary
Modifier and TypeMethodDescriptionprotected double
attractiveForce
(double distance) Calculate the attractive force.calculateAttractiveForces
(Graph<V, E> graph, LayoutModel2D<V> model) Calculate the repulsive forces between vertices connected with edges.calculateRepulsiveForces
(Graph<V, E> graph, LayoutModel2D<V> model) Calculate the repulsive forces between verticesGet the initializerprotected void
Initialize a model using the initializer.void
Layout a graph.protected double
repulsiveForce
(double distance) Calculate the repulsive force.void
setInitializer
(Function<V, Point2D> initializer) Set the initializer
-
Field Details
-
DEFAULT_ITERATIONS
public static final int DEFAULT_ITERATIONSDefault number of iterations- See Also:
-
DEFAULT_NORMALIZATION_FACTOR
public static final double DEFAULT_NORMALIZATION_FACTORDefault normalization factor when calculating optimal distance- See Also:
-
rng
-
optimalDistance
protected double optimalDistance -
normalizationFactor
protected double normalizationFactor -
iterations
protected int iterations -
temperatureModelSupplier
protected BiFunction<LayoutModel2D<V>,Integer, temperatureModelSupplierFRLayoutAlgorithm2D.TemperatureModel> -
comparator
-
initializer
A model initializer
-
-
Constructor Details
-
FRLayoutAlgorithm2D
public FRLayoutAlgorithm2D()Create a new layout algorithm -
FRLayoutAlgorithm2D
public FRLayoutAlgorithm2D(int iterations) Create a new layout algorithm- Parameters:
iterations
- number of iterations
-
FRLayoutAlgorithm2D
public FRLayoutAlgorithm2D(int iterations, double normalizationFactor) Create a new layout algorithm- Parameters:
iterations
- number of iterationsnormalizationFactor
- normalization factor for the optimal distance
-
FRLayoutAlgorithm2D
Create a new layout algorithm- Parameters:
iterations
- number of iterationsnormalizationFactor
- normalization factor for the optimal distancerng
- the random number generator
-
FRLayoutAlgorithm2D
public FRLayoutAlgorithm2D(int iterations, double normalizationFactor, Random rng, double tolerance) Create a new layout algorithm- Parameters:
iterations
- number of iterationsnormalizationFactor
- normalization factor for the optimal distancerng
- the random number generatortolerance
- tolerance used when comparing floating point values
-
FRLayoutAlgorithm2D
public FRLayoutAlgorithm2D(int iterations, double normalizationFactor, BiFunction<LayoutModel2D<V>, Integer, FRLayoutAlgorithm2D.TemperatureModel> temperatureModelSupplier, Random rng) Create a new layout algorithm- Parameters:
iterations
- number of iterationsnormalizationFactor
- normalization factor for the optimal distancetemperatureModelSupplier
- a simulated annealing temperature model supplierrng
- the random number generator
-
FRLayoutAlgorithm2D
public FRLayoutAlgorithm2D(int iterations, double normalizationFactor, BiFunction<LayoutModel2D<V>, Integer, FRLayoutAlgorithm2D.TemperatureModel> temperatureModelSupplier, Random rng, double tolerance) Create a new layout algorithm- Parameters:
iterations
- number of iterationsnormalizationFactor
- normalization factor for the optimal distancetemperatureModelSupplier
- a simulated annealing temperature model supplierrng
- the random number generatortolerance
- tolerance used when comparing floating point values
-
-
Method Details
-
layout
Description copied from interface:LayoutAlgorithm2D
Layout a graph.- Parameters:
graph
- the graphmodel
- the layout model to use
-
attractiveForce
protected double attractiveForce(double distance) Calculate the attractive force.- Parameters:
distance
- the distance- Returns:
- the force
-
repulsiveForce
protected double repulsiveForce(double distance) Calculate the repulsive force.- Parameters:
distance
- the distance- Returns:
- the force
-
calculateRepulsiveForces
Calculate the repulsive forces between vertices- Parameters:
graph
- the graphmodel
- the model- Returns:
- the displacement per vertex due to the repulsive forces
-
calculateAttractiveForces
Calculate the repulsive forces between vertices connected with edges.- Parameters:
graph
- the graphmodel
- the model- Returns:
- the displacement per vertex due to the attractive forces
-
getInitializer
Get the initializer- Returns:
- the initializer
-
setInitializer
Set the initializer- Parameters:
initializer
- the initializer
-
init
Initialize a model using the initializer.- Parameters:
graph
- the graphmodel
- the model
-