Class RandomForestGenerator

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

public class RandomForestGenerator extends AbstractGraphGenerator
Generates a random forest. A forest is a collection of disjoint trees. A forest can also be defined as an acyclic graph, either connected (in which case it is a tree) or disconnected. A forest with k components and n nodes has n-k edges.
Author:
Cristian Frăsinaru
  • Constructor Details

    • RandomForestGenerator

      public RandomForestGenerator(int numVertices)
      Creates a generator for a forest with vertices ranging from 0 to numVertices - 1, containing a random number of disjoint trees.
      Parameters:
      numVertices - the number of vertices of the generated forest.
    • RandomForestGenerator

      public RandomForestGenerator(int numVertices, int numTrees)
      Creates a generator for a forest with vertices ranging from 0 to numVertices - 1, containing a specified number of disjoint trees.
      Parameters:
      numVertices - the number of vertices of the generated forest.
      numTrees - the number of disjoint trees.
    • RandomForestGenerator

      public RandomForestGenerator(int firstVertex, int lastVertex, int numTrees)
      Creates a generator for a forest with vertices ranging from firstVertex to lastVertex, containing a specified number of disjoint trees.
      Parameters:
      firstVertex - the number of the first vertex in the generated forest.
      lastVertex - the number of the last vertex in the generated forest.
      numTrees - the number of disjoint trees.
  • Method Details

    • createForest

      public Graph createForest()
      Creates a random forest.
      Returns:
      a random forest.