org.apache.spark.graphx.util
Class GraphGenerators

Object
  extended by org.apache.spark.graphx.util.GraphGenerators

public class GraphGenerators
extends Object

A collection of graph generating functions.


Constructor Summary
GraphGenerators()
           
 
Method Summary
static Edge<Object>[] generateRandomEdges(int src, int numEdges, int maxVertexId, long seed)
           
static Graph<scala.Tuple2<Object,Object>,Object> gridGraph(SparkContext sc, int rows, int cols)
          Create rows by cols grid graph with each vertex connected to its row+1 and col+1 neighbors.
static Graph<Object,Object> logNormalGraph(SparkContext sc, int numVertices, int numEParts, double mu, double sigma, long seed)
          Generate a graph whose vertex out degree distribution is log normal.
static double RMATa()
           
static double RMATb()
           
static double RMATc()
           
static double RMATd()
           
static Graph<Object,Object> rmatGraph(SparkContext sc, int requestedNumVertices, int numEdges)
          A random graph generator using the R-MAT model, proposed in "R-MAT: A Recursive Model for Graph Mining" by Chakrabarti et al.
static Graph<Object,Object> starGraph(SparkContext sc, int nverts)
          Create a star graph with vertex 0 being the center.
 
Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GraphGenerators

public GraphGenerators()
Method Detail

RMATa

public static double RMATa()

RMATb

public static double RMATb()

RMATd

public static double RMATd()

logNormalGraph

public static Graph<Object,Object> logNormalGraph(SparkContext sc,
                                                  int numVertices,
                                                  int numEParts,
                                                  double mu,
                                                  double sigma,
                                                  long seed)
Generate a graph whose vertex out degree distribution is log normal.

The default values for mu and sigma are taken from the Pregel paper:

Grzegorz Malewicz, Matthew H. Austern, Aart J.C Bik, James C. Dehnert, Ilan Horn, Naty Leiser, and Grzegorz Czajkowski. 2010. Pregel: a system for large-scale graph processing. SIGMOD '10.

If the seed is -1 (default), a random seed is chosen. Otherwise, use the user-specified seed.

Parameters:
sc - Spark Context
numVertices - number of vertices in generated graph
numEParts - (optional) number of partitions
mu - (optional, default: 4.0) mean of out-degree distribution
sigma - (optional, default: 1.3) standard deviation of out-degree distribution
seed - (optional, default: -1) seed for RNGs, -1 causes a random seed to be chosen
Returns:
Graph object

RMATc

public static double RMATc()

generateRandomEdges

public static Edge<Object>[] generateRandomEdges(int src,
                                                 int numEdges,
                                                 int maxVertexId,
                                                 long seed)

rmatGraph

public static Graph<Object,Object> rmatGraph(SparkContext sc,
                                             int requestedNumVertices,
                                             int numEdges)
A random graph generator using the R-MAT model, proposed in "R-MAT: A Recursive Model for Graph Mining" by Chakrabarti et al.

See http://www.cs.cmu.edu/~christos/PUBLICATIONS/siam04.pdf.

Parameters:
sc - (undocumented)
requestedNumVertices - (undocumented)
numEdges - (undocumented)
Returns:
(undocumented)

gridGraph

public static Graph<scala.Tuple2<Object,Object>,Object> gridGraph(SparkContext sc,
                                                                  int rows,
                                                                  int cols)
Create rows by cols grid graph with each vertex connected to its row+1 and col+1 neighbors. Vertex ids are assigned in row major order.

Parameters:
sc - the spark context in which to construct the graph
rows - the number of rows
cols - the number of columns

Returns:
A graph containing vertices with the row and column ids as their attributes and edge values as 1.0.

starGraph

public static Graph<Object,Object> starGraph(SparkContext sc,
                                             int nverts)
Create a star graph with vertex 0 being the center.

Parameters:
sc - the spark context in which to construct the graph
nverts - the number of vertices in the star

Returns:
A star graph containing nverts vertices with vertex 0 being the center vertex.