Class LayoutUtil

java.lang.Object
edu.cmu.tetrad.graph.LayoutUtil

public class LayoutUtil extends Object

LayoutUtil class.

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

    • LayoutUtil

      public LayoutUtil()
      Constructor.
  • Method Details

    • kamadaKawaiLayout

      public static void kamadaKawaiLayout(Graph graph, boolean randomlyInitialized, double naturalEdgeLength, double springConstant, double stopEnergy)

      kamadaKawaiLayout.

      Parameters:
      graph - a Graph object
      randomlyInitialized - a boolean
      naturalEdgeLength - a double
      springConstant - a double
      stopEnergy - a double
    • fruchtermanReingoldLayout

      public static void fruchtermanReingoldLayout(Graph graph)

      fruchtermanReingoldLayout.

      Parameters:
      graph - a Graph object
    • arrangeByLayout

      public static void arrangeByLayout(Graph graph, HashMap<String,PointXy> layout)

      arrangeByLayout.

      Parameters:
      graph - a Graph object
      layout - a HashMap object
    • defaultLayout

      public static void defaultLayout(Graph graph)
      Arranges the nodes in the graph in a circle if there are 20 or fewer nodes, otherwise arranges them in a square.
      Parameters:
      graph - the graph to be arranged.
    • circleLayout

      public static void circleLayout(Graph graph)
      Arranges the nodes in the graph in a circle.
      Parameters:
      graph - the graph to be arranged.
    • squareLayout

      public static void squareLayout(Graph graph)

      squareLayout.

      Parameters:
      graph - a Graph object
    • layoutByCausalOrder

      public static void layoutByCausalOrder(Graph graph)

      layoutByCausalOrder.

      Parameters:
      graph - a Graph object
    • arrangeBySourceGraph

      public static boolean arrangeBySourceGraph(Graph resultGraph, Graph sourceGraph)
      Arranges the nodes in the result graph according to their positions in the source graph.
      Parameters:
      resultGraph - a Graph object
      sourceGraph - a Graph object
      Returns:
      true if all the nodes were arranged, false if not.
    • repositionLatents

      public static void repositionLatents(Graph graph)
      Repositions latent nodes in the given graph based on their non-latent neighbors.

      This method iterates through all nodes in the graph, identifies latent nodes, and repositions them using the non-latent neighbors only. The method works by filtering out latent neighbors of each latent node before repositioning.

      Parameters:
      graph - the graph containing the nodes to be repositioned.
    • positionLatentNode

      public static void positionLatentNode(Node latent, Set<Node> neighbors)
      Positions a latent node based on the average position of its measured neighbors. The method calculates the average x and y coordinates of the measured neighbors and repositions the latent node to this calculated center.
      Parameters:
      latent - the latent node to be positioned
      neighbors - the set of neighboring nodes; only measured neighbors are used to calculate the position