Class RandomDAGGenerator

java.lang.Object
org.graph4j.generators.AbstractGraphGenerator
org.graph4j.generators.RandomDAGGenerator

public class RandomDAGGenerator extends AbstractGraphGenerator
Generates a random directed acyclic graph (DAG). Each possible arc is added considering a given probability.
Author:
Cristian Frăsinaru
See Also:
  • Constructor Details

    • RandomDAGGenerator

      public RandomDAGGenerator(int numVertices, double edgeProbability)
      Parameters:
      numVertices - number of vertices.
      edgeProbability - probability that two vertices are connected.
    • RandomDAGGenerator

      public RandomDAGGenerator(int firstVertex, int lastVertex, double edgeProbability)
      Parameters:
      firstVertex - first vertex number of the graph.
      lastVertex - last vertex number of the graph.
      edgeProbability - probability that two vertices are connected.
  • Method Details

    • createDAG

      public Digraph createDAG()
      Returns:
      a random directed acyclic graph.
    • getTopologicalOrdering

      public int[] getTopologicalOrdering()
      The method returns the topological ordering of the vertices, based on which the DAG was created.
      Returns:
      the topological ordering of the generated DAG.