- pylibcugraph.node2vec(ResourceHandle resource_handle, _GPUGraph graph, seed_array, size_t max_depth, bool_t compress_result, double p, double q)#
Computes random walks under node2vec sampling procedure.
Handle to the underlying device resources needed for referencing data and running algorithms.
The input graph.
- seed_array: device array type
Device array containing the pointer to the array of seed vertices.
Maximum number of vertices in generated path
If true, the paths are unpadded and a third return device array contains the sizes for each path, otherwise the paths are padded and the third return device array is empty.
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”.
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.
- 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, and the third item is a device array containing the sizes
- for each of the compressed paths, if compress_result is True.
>>> 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, weights, ... store_transposed=False, renumber=False, do_expensive_check=False) >>> (paths, weights, sizes) = pylibcugraph.node2vec( ... resource_handle, G, seeds, 3, True, 1.0, 1.0)