Package org.jungrapht.samples.util
Class TestGraphs
- java.lang.Object
-
- org.jungrapht.samples.util.TestGraphs
-
public class TestGraphs extends Object
Provides generators for several different test graphs.
-
-
Constructor Summary
Constructors Constructor Description TestGraphs()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static org.jgrapht.Graph<String,Integer>createChainPlusIsolates(int chain_length, int isolate_count)static org.jgrapht.Graph<String,Integer>createDirectedAcyclicGraph(int layers, int maxVerticesPerLayer, double linkprob)Creates a sample directed acyclic graph by generating several "layers", and connecting vertices (randomly) to vertices in earlier (but never later) layers.static org.jgrapht.Graph<String,Integer>createDirectedAcyclicGraph(int layers, int maxVerticesPerLayer, double linkprob, long randomSeed)static org.jgrapht.Graph<String,Integer>createSmallGraph(boolean directed)static org.jgrapht.Graph<String,Integer>createTestGraph(boolean directed)Creates a small sample graph that can be used for testing purposes.static org.jgrapht.Graph<String,Integer>getDemoGraph()Returns a bigger test graph with a clique, several components, and other parts.static org.jgrapht.Graph<String,Integer>getDemoGraph(boolean directed)Returns a bigger test graph with a clique, several components, and other parts.static org.jgrapht.Graph<String,Integer>getGeneratedBipartiteGraph()static org.jgrapht.Graph<String,Integer>getGeneratedGraph()static org.jgrapht.Graph<String,Integer>getGeneratedGraph2()static org.jgrapht.Graph<String,Integer>getOneComponentGraph()Returns a bigger, undirected test graph with a just one component.static <T> org.jgrapht.Graph<T,Integer>getOneComponentGraph(Supplier<T> factory)static org.jgrapht.Graph<String,Integer>getOneVertexGraph()
-
-
-
Field Detail
-
pairs
public static String[][] pairs
A series of pairs that may be useful for generating graphs. The miniature graph consists of 8 edges, 10 vertices, and is formed of two connected components, one of 8 vertices, the other of 2.
-
-
Method Detail
-
createTestGraph
public static org.jgrapht.Graph<String,Integer> createTestGraph(boolean directed)
Creates a small sample graph that can be used for testing purposes. The graph is as described in the section onpairs.- Parameters:
directed- true iff the graph created is to have directed edges- Returns:
- a graph consisting of eight edges and ten vertices.
-
createChainPlusIsolates
public static org.jgrapht.Graph<String,Integer> createChainPlusIsolates(int chain_length, int isolate_count)
- Parameters:
chain_length- the length of the chain of vertices to add to the returned graphisolate_count- the number of isolated vertices to add to the returned graph- Returns:
- a graph consisting of a chain of
chain_lengthvertices andisolate_countisolated vertices.
-
createDirectedAcyclicGraph
public static org.jgrapht.Graph<String,Integer> createDirectedAcyclicGraph(int layers, int maxVerticesPerLayer, double linkprob)
Creates a sample directed acyclic graph by generating several "layers", and connecting vertices (randomly) to vertices in earlier (but never later) layers. The number of vertices in each layer is a random value in the range [1, maxVerticesPerLayer].- Parameters:
layers- the number of layers of vertices to create in the graphmaxVerticesPerLayer- the maximum number of vertices to put in any layerlinkprob- the probability that this method will add an edge from a vertex in layer k to a vertex in layer k+1- Returns:
- the created graph
-
createDirectedAcyclicGraph
public static org.jgrapht.Graph<String,Integer> createDirectedAcyclicGraph(int layers, int maxVerticesPerLayer, double linkprob, long randomSeed)
-
getOneComponentGraph
public static org.jgrapht.Graph<String,Integer> getOneComponentGraph()
Returns a bigger, undirected test graph with a just one component. This graph consists of a clique of ten edges, a partial clique (randomly generated, with edges of 0.6 probability), and one series of edges running from the first vertex to the last.- Returns:
- the testgraph
-
getOneComponentGraph
public static <T> org.jgrapht.Graph<T,Integer> getOneComponentGraph(Supplier<T> factory)
-
getDemoGraph
public static org.jgrapht.Graph<String,Integer> getDemoGraph()
Returns a bigger test graph with a clique, several components, and other parts.- Returns:
- a demonstration graph of type UndirectedSparseMultiGraph with 28 vertices.
-
getDemoGraph
public static org.jgrapht.Graph<String,Integer> getDemoGraph(boolean directed)
Returns a bigger test graph with a clique, several components, and other parts.- Parameters:
directed- true if the supplied graph should be directed- Returns:
- a demonstration graph of type UndirectedSparseMultiGraph with 28 vertices.
-
createSmallGraph
public static org.jgrapht.Graph<String,Integer> createSmallGraph(boolean directed)
-
getGeneratedGraph
public static org.jgrapht.Graph<String,Integer> getGeneratedGraph()
- Returns:
- the graph for this demo
-
-