Package org.jungrapht.samples.util
Class TestGuavaGraphs
- java.lang.Object
-
- org.jungrapht.samples.util.TestGuavaGraphs
-
public class TestGuavaGraphs extends Object
Provides generators for several different test graphs.
-
-
Constructor Summary
Constructors Constructor Description TestGuavaGraphs()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static com.google.common.graph.MutableGraph<String>
createChainPlusIsolates(int chain_length, int isolate_count)
static com.google.common.graph.MutableGraph<String>
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 com.google.common.graph.MutableGraph<String>
createSmallGraph(boolean directed)
static com.google.common.graph.MutableGraph<String>
createTestGraph(boolean directed)
Creates a small sample graph that can be used for testing purposes.static com.google.common.graph.MutableGraph<String>
getDemoGraph()
Returns a bigger test graph with a clique, several components, and other parts.static com.google.common.graph.MutableGraph<String>
getGeneratedGraph()
static com.google.common.graph.MutableGraph<String>
getOneComponentGraph()
Returns a bigger, undirected test graph with a just one component.
-
-
-
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 com.google.common.graph.MutableGraph<String> 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 com.google.common.graph.MutableGraph<String> 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_length
vertices andisolate_count
isolated vertices.
-
createDirectedAcyclicGraph
public static com.google.common.graph.MutableGraph<String> 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
-
getOneComponentGraph
public static com.google.common.graph.MutableGraph<String> 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
-
getDemoGraph
public static com.google.common.graph.MutableGraph<String> getDemoGraph()
Returns a bigger test graph with a clique, several components, and other parts.- Returns:
- a demonstration graph of type UndirectedSparseMultiGraph with 28 vertices.
-
createSmallGraph
public static com.google.common.graph.MutableGraph<String> createSmallGraph(boolean directed)
-
getGeneratedGraph
public static com.google.common.graph.MutableGraph<String> getGeneratedGraph()
- Returns:
- the graph for this demo
-
-