Class LayoutUtil.FruchtermanReingoldLayout

java.lang.Object
edu.cmu.tetrad.graph.LayoutUtil.FruchtermanReingoldLayout
Enclosing class:
LayoutUtil

public static final class LayoutUtil.FruchtermanReingoldLayout extends Object
Lays out a graph by linearly summing repulsive force between all nodes and attractive force between adjacent nodes. Includes a linear cooling schedule and early termination when the layout stabilizes.

Two departures from the textbook forces keep edge lengths even. Each node repels in proportion to the square root of its degree plus one, so a leaf is pushed less than a hub; and each edge's pull is divided by the square root of the smaller degree of its two endpoints, so edges inside densely connected regions relax while an edge to a leaf keeps its full strength. A final pass separates any node boxes that still overlap, and components are packed in rows under the largest one.

Version:
$Id: $Id
Author:
josephramsey
  • Constructor Details

    • FruchtermanReingoldLayout

      public FruchtermanReingoldLayout(Graph graph)
      Constructs a new FruchtermanReingoldLayout for the given graph.
      Parameters:
      graph - the graph to be laid out.
  • Method Details

    • setNaturalEdgeLength

      public void setNaturalEdgeLength(double naturalEdgeLength)
      Sets the natural edge length, the distance at which an edge's pull and its endpoints' mutual push balance. Edges settle to about twice it in practice; see LayoutUtil.fruchtermanReingoldLayout(Graph, double). Zero or less means automatic: 20 + 20 times the average degree of the graph, which grows with density and spreads a dense graph widely.
      Parameters:
      naturalEdgeLength - the length in pixels, or 0 for automatic.
    • doLayout

      public void doLayout()
      Lays out the graph.