edu.uci.ics.jung.utils
Class TestGraphs

java.lang.Object
  extended by edu.uci.ics.jung.utils.TestGraphs

public class TestGraphs
extends Object

Generates a series of potentially useful test graphs.

Author:
danyelf

Field Summary
static String[][] pairs
          A series of pairs that may be useful for generating graphs.
 
Constructor Summary
TestGraphs()
           
 
Method Summary
static Graph createChainPlusIsolates(int chain_length, int isolate_count)
          Returns a graph consisting of a chain of vertex_count - 1 vertices plus one isolated vertex.
static Graph 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.
static AbstractSparseGraph createTestGraph(boolean isDirected)
          Creates a small sample graph that can be used for testing purposes.
static Graph generateMixedRandomGraph(NumberEdgeValue edge_weight, int num_vertices)
          Equivalent to generateMixedRandomGraph(edge_weight, num_vertices, true).
static Graph generateMixedRandomGraph(NumberEdgeValue edge_weights, int num_vertices, boolean parallel)
          Returns a random mixed-mode graph.
static Graph getDemoGraph()
          Returns a bigger test graph with a clique, several components, and other parts.
static Graph getOneComponentGraph()
          Returns a bigger, undirected test graph with a just one component.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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 nodes, and is formed of two connected components, one of 8 nodes, the other of 2.

Constructor Detail

TestGraphs

public TestGraphs()
Method Detail

createTestGraph

public static AbstractSparseGraph createTestGraph(boolean isDirected)
Creates a small sample graph that can be used for testing purposes. The graph is as described in the section on pairs. If isDirected, the graph is a DirectedSparseGraph, otherwise, it is an UndirectedSparseGraph.

Parameters:
isDirected: - Is the graph directed?
Returns:
a graph consisting of eight edges and ten nodes.

createChainPlusIsolates

public static Graph createChainPlusIsolates(int chain_length,
                                            int isolate_count)
Returns a graph consisting of a chain of vertex_count - 1 vertices plus one isolated vertex.


createDirectedAcyclicGraph

public static Graph 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. Each layer has some random number of nodes in it 1 less than n less than maxNodesPerLayer.

Returns:
the created graph

getOneComponentGraph

public static Graph 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

public static Graph getDemoGraph()
Returns a bigger test graph with a clique, several components, and other parts.

Returns:
a demonstration graph of type UndirectedSparseGraph with 28 vertices.

generateMixedRandomGraph

public static Graph generateMixedRandomGraph(NumberEdgeValue edge_weight,
                                             int num_vertices)
Equivalent to generateMixedRandomGraph(edge_weight, num_vertices, true).


generateMixedRandomGraph

public static Graph generateMixedRandomGraph(NumberEdgeValue edge_weights,
                                             int num_vertices,
                                             boolean parallel)
Returns a random mixed-mode graph. Starts with a randomly generated Barabasi-Albert (preferential attachment) generator (4 initial vertices, 3 edges added at each step, and num_vertices - 4 evolution steps). Then takes the resultant graph, replaces random undirected edges with directed edges, and assigns random weights to each edge.