public class GraphGenerator extends java.lang.Object
For additional documentation, see Section 4.1 of Algorithms, 4th Edition, by Robert Sedgewick and Kevin Wayne.
Constructor and Description |
---|
GraphGenerator() |
Modifier and Type | Method and Description |
---|---|
static Graph |
binaryTree(int V)
Returns a complete binary tree graph on V vertices.
|
static Graph |
bipartite(int V1,
int V2,
double p)
Returns a random simple bipartite graph on V1 and V2 vertices,
containing each possible edge with probability p.
|
static Graph |
bipartite(int V1,
int V2,
int E)
Returns a random simple bipartite graph on V1 and V2 vertices
with E edges.
|
static Graph |
complete(int V)
Returns the complete graph on V vertices.
|
static Graph |
completeBipartite(int V1,
int V2)
Returns a complete bipartite graph on V1 and V2 vertices.
|
static Graph |
cycle(int V)
Returns a cycle graph on V vertices.
|
static void |
main(java.lang.String[] args)
Unit tests the GraphGenerator library.
|
static Graph |
path(int V)
Returns a path graph on V vertices.
|
static Graph |
regular(int V,
int k)
Returns a uniformly random k-regular graph on V vertices
(not necessarily simple).
|
static Graph |
simple(int V,
double p)
Returns a random simple graph on V vertices, with an
edge between any two vertices with probability p.
|
static Graph |
simple(int V,
int E)
Returns a random simple graph containing V vertices and E edges.
|
static Graph |
star(int V)
Returns a star graph on V vertices.
|
static Graph |
tree(int V)
Returns a uniformly random tree on V vertices.
|
static Graph |
wheel(int V)
Returns a wheel graph on V vertices.
|
public static Graph simple(int V, int E)
V
- the number of verticesE
- the number of verticesjava.lang.IllegalArgumentException
- if no such simple graph existspublic static Graph simple(int V, double p)
V
- the number of verticesp
- the probability of choosing an edgejava.lang.IllegalArgumentException
- if probability is not between 0 and 1public static Graph complete(int V)
V
- the number of verticespublic static Graph completeBipartite(int V1, int V2)
V1
- the number of vertices in one partitionV2
- the number of vertices in the other partitionjava.lang.IllegalArgumentException
- if probability is not between 0 and 1public static Graph bipartite(int V1, int V2, int E)
V1
- the number of vertices in one partitionV2
- the number of vertices in the other partitionE
- the number of edgesjava.lang.IllegalArgumentException
- if no such simple bipartite graph existspublic static Graph bipartite(int V1, int V2, double p)
V1
- the number of vertices in one partitionV2
- the number of vertices in the other partitionp
- the probability that the graph contains an edge with one endpoint in either sidejava.lang.IllegalArgumentException
- if probability is not between 0 and 1public static Graph path(int V)
V
- the number of vertices in the pathpublic static Graph binaryTree(int V)
V
- the number of vertices in the binary treepublic static Graph cycle(int V)
V
- the number of vertices in the cyclepublic static Graph wheel(int V)
V
- the number of vertices in the wheelpublic static Graph star(int V)
V
- the number of vertices in the starpublic static Graph regular(int V, int k)
V
- the number of vertices in the graphpublic static Graph tree(int V)
V
- the number of vertices in the treepublic static void main(java.lang.String[] args)