Class GraphFactoryUtil

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

public class GraphFactoryUtil extends Object
Utility class providing factory methods for creating instances of different types of Graph objects. This class allows for the creation of graphs with specific configurations or replication policies.
  • Method Details

    • newGraph

      public static Graph newGraph(boolean replicating)
      Creates a new instance of a Graph with the specified replication policy. The graph is initialized with an empty list of nodes.
      Parameters:
      replicating - whether the graph should support replication functionality.
      Returns:
      a new Graph instance configured according to the replication policy.
    • newGraph

      public static Graph newGraph(List<Node> nodes, boolean replicating)
      Creates a new instance of a Graph initialized with the provided list of nodes. Depending on the `replicating` flag, the method returns either a replicable graph or a standard edge-list-based graph.
      Parameters:
      nodes - the list of nodes to initialize the graph with
      replicating - whether the graph should support replication functionality
      Returns:
      a new Graph instance configured based on the replication policy and node list
    • newGraph

      public static Graph newGraph(Graph graph)
      Creates a new instance of a Graph based on the given graph. If the input graph is an instance of ReplicatingGraph, a new ReplicatingGraph is created as a copy of the input graph. Otherwise, a new EdgeListGraph is created initialized with the nodes from the input graph.
      Parameters:
      graph - the source graph used to create a new graph instance
      Returns:
      a new Graph instance, either a ReplicatingGraph or an EdgeListGraph, based on the type of the provided graph