-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature] Random walk traces generation (dmlc#392)
* random walk traces generation * remove outdated comments * oops put in the wrong place * explicit inline * moving rand_r to util * moving random walk to public function * per-thread seed and openmp support * type cast styles
- Loading branch information
Showing
9 changed files
with
148 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
from .sampler import NeighborSampler | ||
from .randomwalk import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
|
||
from ... import utils | ||
from ... import backend as F | ||
|
||
__all__ = ['random_walk'] | ||
|
||
|
||
def random_walk(g, seeds, num_traces, num_hops): | ||
"""Batch-generate random walk traces on given graph with the same length. | ||
Parameters | ||
---------- | ||
g : DGLGraph | ||
The graph. Must be readonly. | ||
seeds : Tensor | ||
The node ID tensor from which the random walk traces starts. | ||
num_traces : int | ||
Number of traces to generate for each seed. | ||
num_hops : int | ||
Number of hops for each trace. | ||
Returns | ||
------- | ||
traces : Tensor | ||
A 3-dimensional node ID tensor with shape | ||
(num_seeds, num_traces, num_hops + 1) | ||
traces[i, j, 0] are always starting nodes (i.e. seed[i]). | ||
""" | ||
return g._graph.random_walk(utils.toindex(seeds), num_traces, num_hops) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters