Package edu.uci.ics.jung.graph.util
Class TestGraphs
java.lang.Object
edu.uci.ics.jung.graph.util.TestGraphs
Provides generators for several different test graphs.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateChainPlusIsolates
(int chain_length, int isolate_count) createDirectedAcyclicGraph
(int layers, int maxNodesPerLayer, double linkprob) Creates a sample directed acyclic graph by generating several "layers", and connecting nodes (randomly) to nodes in earlier (but never later) layers.private static void
createTestGraph
(boolean directed) Creates a small sample graph that can be used for testing purposes.Returns a bigger test graph with a clique, several components, and other parts.Returns a bigger, undirected test graph with a just one component.
-
Field Details
-
pairs
A series of pairs that may be useful for generating graphs. The miniature graph consists of 8 edges, 10 nodes, and is formed of two connected components, one of 8 nodes, the other of 2.
-
-
Constructor Details
-
TestGraphs
public TestGraphs()
-
-
Method Details
-
createTestGraph
Creates a small sample graph that can be used for testing purposes. The graph is as described in the section onpairs
. IfisDirected
, the graph is aDirectedSparseMultigraph
, otherwise, it is anUndirectedSparseMultigraph
.- Parameters:
directed
- true iff the graph created is to have directed edges- Returns:
- a graph consisting of eight edges and ten nodes.
-
createChainPlusIsolates
- 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 Graph<String,Number> createDirectedAcyclicGraph(int layers, int maxNodesPerLayer, double linkprob) Creates a sample directed acyclic graph by generating several "layers", and connecting nodes (randomly) to nodes in earlier (but never later) layers. The number of vertices in each layer is a random value in the range [1, maxNodesPerLayer].- Parameters:
layers
- the number of layers of vertices to create in the graphmaxNodesPerLayer
- 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
-
createEdge
-
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 node to the last.- Returns:
- the testgraph
-
getDemoGraph
Returns a bigger test graph with a clique, several components, and other parts.- Returns:
- a demonstration graph of type UndirectedSparseMultigraph with 28 vertices.
-
getSmallGraph
- Returns:
- a small graph with directed and undirected edges, and parallel edges.
-