Package org.graph4j.generators
Class RandomForestGenerator
java.lang.Object
org.graph4j.generators.AbstractGraphGenerator
org.graph4j.generators.RandomForestGenerator
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
-
Field Summary
Fields inherited from class org.graph4j.generators.AbstractGraphGenerator
vertices -
Constructor Summary
ConstructorsConstructorDescriptionRandomForestGenerator(int numVertices) Creates a generator for a forest with vertices ranging from 0 tonumVertices - 1, containing a random number of disjoint trees.RandomForestGenerator(int numVertices, int numTrees) Creates a generator for a forest with vertices ranging from 0 tonumVertices - 1, containing a specified number of disjoint trees.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. -
Method Summary
Methods inherited from class org.graph4j.generators.AbstractGraphGenerator
addRandomEdges
-
Constructor Details
-
RandomForestGenerator
public RandomForestGenerator(int numVertices) Creates a generator for a forest with vertices ranging from 0 tonumVertices - 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 tonumVertices - 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
Creates a random forest.- Returns:
- a random forest.
-