Package org.graph4j.generators
Class GraphGenerator
java.lang.Object
org.graph4j.generators.GraphGenerator
Static methods for generating various standard graphs. Most of the methods
are shortcuts to a corresponding class responsible with the actual creation
of the graph.
- Author:
- Cristian Frăsinaru
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Graphcomplete(int numVertices) Generates a complete graph.static GraphcompleteBipartite(int n1, int n2) Generates a complete bipartite graph.static GraphcompleteMultipartite(int... numVertices) Generates a complete multipartite graph.static GraphcompleteTree(int numLevels, int degree) Generates a complete tree.static Graphcycle(int numVertices) Generates a random cycle graph.static Graphempty(int numVertices) Creates a graph with a specified number of vertices and no edges.static Graphfan(int m, int n) Generates a fan graph (a join between an empty graph and a path).static Graphgrid(int rows, int cols) Generates a grid graph.static Graphmycielski(int chromaticNumber) Generates a Mycielski graph with the specified chromatic number.static Graphpath(int numVertices) Generates a random path graph.static DigraphrandomArborescence(int numVertices) Generates a random arborescence.static GraphrandomChordalGraph(int numVertices) Generates a random chordal graph.static DigraphrandomDAG(int numVertices, double edgeProbability) Generates a random directed acyclic graph (DAG).static GraphrandomForest(int numVertices) Generates a random forest.static GraphrandomGnm(int numVertices, int numEdges) Generates a random G(n,m) graph.static GraphrandomGnmBipartite(int n1, int n2, int m) Generates a random Gnm bipartite graph.static GraphrandomGnp(int numVertices, double edgeProbability) Generates a random G(n,p) graph.static GraphrandomGnpBipartite(int n1, int n2, double edgeProbability) Generates a random G(n,p) bipartite graph.static DigraphrandomTournament(int numVertices) Generates a random tournament graph.static GraphrandomTree(int numVertices) Generates a random tree.static Graphregular(int numVertices, int degree) Generates a regular graph.static Graphstar(int numVertices) Generates a random star graph.static Graphtrivial(int vertexNumber) Creates a graph with a single vertex having the specified number.static Graphwheel(int numVertices) Generates a random wheel graph.
-
Constructor Details
-
GraphGenerator
public GraphGenerator()
-
-
Method Details
-
empty
Creates a graph with a specified number of vertices and no edges.- Parameters:
numVertices- the number of vertices- Returns:
- a graph with n vertices and no edges.
- See Also:
-
trivial
Creates a graph with a single vertex having the specified number.- Parameters:
vertexNumber- the number of the vertex.- Returns:
- a graph with a single vertex and no edges.
- See Also:
-
complete
Generates a complete graph.- Parameters:
numVertices- the number of vertices.- Returns:
- a complete graph with n vertices.
- See Also:
-
randomGnp
Generates a random G(n,p) graph.- Parameters:
numVertices- the number of vertices.edgeProbability- the probability that an edge belongs to the graph.- Returns:
- a random graph.
- See Also:
-
randomGnm
Generates a random G(n,m) graph.- Parameters:
numVertices- the number of vertices.numEdges- the number of edges.- Returns:
- a random graph.
- See Also:
-
completeBipartite
Generates a complete bipartite graph.- Parameters:
n1- the number of vertices in the first partition set.n2- the number of vertices in the second partition set.- Returns:
- a complete bipartite graph.
- See Also:
-
completeMultipartite
Generates a complete multipartite graph.- Parameters:
numVertices- the number of vertices in each partition set.- Returns:
- a complete multipartite graph.
- See Also:
-
randomGnpBipartite
Generates a random G(n,p) bipartite graph.- Parameters:
n1- the number of vertices in the first partition set.n2- the number of vertices in the second partition set.edgeProbability- the probability that an edge belongs to the graph.- Returns:
- a random bipartite graph.
- See Also:
-
randomGnmBipartite
Generates a random Gnm bipartite graph.- Parameters:
n1- the number of vertices in the first partition set.n2- the number of vertices in the second partition set.m- the number of edges.- Returns:
- a random bipartite graph.
- See Also:
-
randomTree
Generates a random tree.- Parameters:
numVertices- the number of vertices.- Returns:
- a random tree.
- See Also:
-
randomArborescence
Generates a random arborescence. The root of the arborescence can be found using the methodGraphMeasures.minIndegreeVertex(org.graph4j.Digraph).- Parameters:
numVertices- the number of vertices.- Returns:
- a random arborescence.
- See Also:
-
randomForest
Generates a random forest.- Parameters:
numVertices- the number of vertices.- Returns:
- a random forest.
- See Also:
-
randomChordalGraph
Generates a random chordal graph.- Parameters:
numVertices- the number of vertices.- Returns:
- a random chordal graph.
- See Also:
-
path
Generates a random path graph.- Parameters:
numVertices- the number of vertices.- Returns:
- a path graph.
- See Also:
-
cycle
Generates a random cycle graph.- Parameters:
numVertices- the number of vertices.- Returns:
- a cycle graph.
- See Also:
-
wheel
Generates a random wheel graph.- Parameters:
numVertices- the number of vertices.- Returns:
- a wheel graph.
- See Also:
-
star
Generates a random star graph.- Parameters:
numVertices- the number of vertices- Returns:
- a star graph.
- See Also:
-
completeTree
Generates a complete tree.- Parameters:
numLevels- the number of levels of the tree.degree- the degree of the internal nodes.- Returns:
- a complete tree.
- See Also:
-
regular
Generates a regular graph.- Parameters:
numVertices- the number of vertices.degree- the degree of all vertices.- Returns:
- a regular graph.
- See Also:
-
grid
Generates a grid graph.- Parameters:
rows- number of rows.cols- number of columns.- Returns:
- a grid graph.
- See Also:
-
randomDAG
Generates a random directed acyclic graph (DAG).- Parameters:
numVertices- number of vertices.edgeProbability- the probability that an edge belongs to the graph.- Returns:
- a random DAG.
- See Also:
-
randomTournament
Generates a random tournament graph.- Parameters:
numVertices- the number of vertices.- Returns:
- a randomly generated tournament.
- See Also:
-
fan
Generates a fan graph (a join between an empty graph and a path).- Parameters:
m- the number of vertices in the empty graph.n- the number of vertices in the path graph.- Returns:
- a fan graph.
- See Also:
-
mycielski
Generates a Mycielski graph with the specified chromatic number.- Parameters:
chromaticNumber- the number of vertices in the empty graph.- Returns:
- a Mycielski graph having the specified chromatic number.
- See Also:
-