Class RandomGraph.UniformGraphGenerator

java.lang.Object
edu.cmu.tetrad.graph.RandomGraph.UniformGraphGenerator
Enclosing class:
RandomGraph

public static final class RandomGraph.UniformGraphGenerator extends Object
Generates random DAGs uniformly with certain classes of DAGs using variants of Markov chain algorithm by Malancon, Dutour, and Philippe. Pieces of the infrastructure of the algorithm are adapted from the the BNGenerator class by Jaime Shinsuke Ide jaime.ide@poli.usp.br, released under the GNU General Public License, for which the following statement is being included as part of the license agreement:

"The BNGenerator distribution is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation (either version 2 of the License or, at your option, any later version), provided that this notice and the name of the author appear in all copies. "If you're using the software, please notify jaime.ide@poli.usp.br so that you can receive updates and patches. BNGenerator is distributed "as is", in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with the BNGenerator distribution. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA."

Author:
josephramsey
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Any DAG uniformly selected
    static final int
    Connected DAG uniformly selected
  • Constructor Summary

    Constructors
    Constructor
    Description
    UniformGraphGenerator(int structure)
    Constructs a random graph generator for the given structure.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Generates a random graph.
    Returns the parent matrix for the graph.
    getDag(List<Node> nodes)
    Returns the parent matrix for the graph.
    void
    Prints the parent matrix for the graph.
    void
    setMaxDegree(int maxDegree)
    Sets the maximum degree of any nodes in the graph.
    void
    setMaxEdges(int maxEdges)
    Sets the maximum number of edges in the graph.
    void
    setMaxInDegree(int maxInDegree)
    Sets the maximum indegree of any node in the graph.
    void
    setMaxOutDegree(int maxOutDegree)
    Sets the maximum outdegree of any node in the graph.
    void
    setNumIterations(int numIterations)
    Sets the number of iterations for the Markov chain process.
    void
    setNumNodes(int numNodes)
    Sets the number of nodes and resets all of the other parameters to default values accordingly.
    A string representation of the structural information for the generated graph.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • ANY_DAG

      public static final int ANY_DAG
      Any DAG uniformly selected
      See Also:
    • CONNECTED_DAG

      public static final int CONNECTED_DAG
      Connected DAG uniformly selected
      See Also:
  • Constructor Details

    • UniformGraphGenerator

      public UniformGraphGenerator(int structure)
      Constructs a random graph generator for the given structure.
      Parameters:
      structure - One of ANY_DAG, POLYTREE, or CONNECTED_DAG.
  • Method Details

    • setNumNodes

      public void setNumNodes(int numNodes)
      Sets the number of nodes and resets all of the other parameters to default values accordingly.
      Parameters:
      numNodes - Must be an integer >= 4.
    • setMaxDegree

      public void setMaxDegree(int maxDegree)
      Sets the maximum degree of any nodes in the graph.
      Parameters:
      maxDegree - An integer between 3 and numNodes - 1, inclusively.
    • setMaxInDegree

      public void setMaxInDegree(int maxInDegree)
      Sets the maximum indegree of any node in the graph.
      Parameters:
      maxInDegree - An integer between 1 and numNodes - 1, inclusively.
    • setMaxOutDegree

      public void setMaxOutDegree(int maxOutDegree)
      Sets the maximum outdegree of any node in the graph.
      Parameters:
      maxOutDegree - An integer between 1 and numNodes - 1, inclusively.
    • setMaxEdges

      public void setMaxEdges(int maxEdges)
      Sets the maximum number of edges in the graph.
      Parameters:
      maxEdges - An integer between 0 and numNodes * (numNodes - 1) / 2, inclusively.
    • setNumIterations

      public void setNumIterations(int numIterations)
      Sets the number of iterations for the Markov chain process.
      Parameters:
      numIterations - An integer >= 1.
    • generate

      public void generate()
      Generates a random graph.
    • getDag

      public Graph getDag()
      Returns the parent matrix for the graph.
      Returns:
      The parent matrix.
    • getDag

      public Graph getDag(List<Node> nodes)
      Returns the parent matrix for the graph.
      Parameters:
      nodes - The nodes to use in the graph.
      Returns:
      The parent matrix.
    • printEdges

      public void printEdges()
      Prints the parent matrix for the graph.
    • toString

      public String toString()
      A string representation of the structural information for the generated graph.
      Overrides:
      toString in class Object