pylibcugraph.node2vec_random_walks#
- pylibcugraph.node2vec_random_walks(
- ResourceHandle resource_handle,
- _GPUGraph graph,
- seed_array,
- size_t max_depth,
- double p,
- double q,
- random_state=None,
Computes random walks under node2vec sampling procedure.
- Parameters:
- resource_handleResourceHandle
Handle to the underlying device resources needed for referencing data and running algorithms.
- graphSGGraph
The input graph.
- seed_array: device array type
Device array containing the pointer to the array of seed vertices.
- max_depthsize_t
Maximum number of vertices in generated path
- pdouble
The return factor p represents the likelihood of backtracking to a node in the walk. A higher value (> max(q, 1)) makes it less likely to sample a previously visited node, while a lower value (< min(q, 1)) would make it more likely to backtrack, making the walk more “local”.
- qdouble
The in-out factor q represents the likelihood of visiting nodes closer or further from the outgoing node. If q > 1, the random walk is likelier to visit nodes closer to the outgoing node. If q < 1, the random walk is likelier to visit nodes further from the outgoing node.
- random_state: int (Optional)
Random state to use when generating samples. Optional argument, defaults to a hash of process id, time, and hostname. (See pylibcugraph.random.CuGraphRandomState)
- Returns:
- A tuple of device arrays, where the first item in the tuple is a device
- array containing the compressed paths, the second item is a device
- array containing the corresponding weights for each edge traversed in
- each path.
Examples
>>> import pylibcugraph, cupy, numpy >>> srcs = cupy.asarray([0, 1, 2], dtype=numpy.int32) >>> dsts = cupy.asarray([1, 2, 3], dtype=numpy.int32) >>> seeds = cupy.asarray([0, 0, 1], dtype=numpy.int32) >>> weights = cupy.asarray([1.0, 1.0, 1.0], dtype=numpy.float32) >>> resource_handle = pylibcugraph.ResourceHandle() >>> graph_props = pylibcugraph.GraphProperties( ... is_symmetric=False, is_multigraph=False) >>> G = pylibcugraph.SGGraph( ... resource_handle, graph_props, srcs, dsts, weight_array=weights, ... store_transposed=False, renumber=False, do_expensive_check=False) >>> (paths, weights) = pylibcugraph.node2vec_random_walks( ... resource_handle, G, seeds, 3, 1.0, 1.0)