cugraph.generators.rmat#

cugraph.generators.rmat(scale, num_edges, a=0.57, b=0.19, c=0.19, seed=42, clip_and_flip=False, scramble_vertex_ids=False, include_edge_weights=False, minimum_weight=None, maximum_weight=None, dtype=None, include_edge_ids=False, include_edge_types=False, min_edge_type_value=None, max_edge_type_value=None, create_using=<class 'cugraph.structure.graph_classes.Graph'>, mg=False)[source]#

Generate a Graph object using a Recursive MATrix (R-MAT) graph generation algorithm.

Parameters:
scaleint

Scale factor to set the number of vertices in the graph. Vertex IDs have values in [0, V), where V = 1 << ‘scale’.

num_edgesint

Number of edges to generate

afloat, optional (default=0.57)

Probability of the edge being in the first partition The Graph 500 spec sets this value to 0.57.

bfloat, optional (default=0.19)

Probability of the edge being in the second partition The Graph 500 spec sets this value to 0.19.

cfloat, optional (default=0.19)

Probability of the edge being in the third partition The Graph 500 spec sets this value to 0.19.

seedint, optional (default=42)

Seed value for the random number generator.

clip_and_flipbool, optional (default=False)

Flag controlling whether to generate edges only in the lower triangular part (including the diagonal) of the graph adjacency matrix (if set to True) or not (if set to ‘false).

scramble_vertex_idsbool, optional (default=False)

Flag controlling whether to scramble vertex ID bits (if set to true) or not (if set to false); scrambling vertex ID bits breaks correlation between vertex ID values and vertex degrees.

include_edge_weightsbool, optional (default=False)

Flag controlling whether to generate edges with weights (if set to True) or not (if set to False).

minimum_weightfloat

Minimum weight value to generate if ‘include_edge_weights’ is True otherwise, this parameter is ignored.

maximum_weightfloat

Maximum weight value to generate if ‘include_edge_weights’ is True otherwise, this parameter is ignored.

dtypenumpy.float32, numpy.float64, cupy.float32, cupy.float64,
“float32”, “float64”

The type of weight to generate which is ignored unless include_weights is true.

include_edge_idsbool, optional (default=False)

Flag controlling whether to generate edges with ids (if set to True) or not (if set to False).

include_edge_typesbool, optional (default=False)

Flag controlling whether to generate edges with types (if set to True) or not (if set to False).

min_edge_type_valueint

Minimum edge type to generate if ‘include_edge_types’ is True otherwise, this parameter is ignored.

max_edge_type_valueint

Maximum edge type to generate if ‘include_edge_types’ is True otherwise, this paramter is ignored.

create_usingcugraph Graph type or None The graph type to construct

containing the generated edges and vertices. If None is specified, the edgelist cuDF DataFrame (or dask_cudf DataFrame for MG) is returned as-is. This is useful for benchmarking Graph construction steps that require raw data that includes potential self-loops, isolated vertices, and duplicated edges. Default is cugraph.Graph.

mgbool, optional (default=False)

If True, R-MAT generation occurs across multiple GPUs. If False, only a single GPU is used. Default is False (single-GPU).

Returns:
instance of cugraph.Graph or cudf or dask_cudf DataFrame

Examples

>>> import cugraph
>>> from cugraph.generators import rmat
>>> scale = 10
>>> edgefactor = 16
>>> df = rmat(
...    scale,
...    (2**scale)*edgefactor,
...    0.57,
...    0.19,
...    0.19,
...    seed=42,
...    clip_and_flip=False,
...    scramble_vertex_ids=True,
...    create_using=None,
...    mg=False
... )