Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dgl
Commits
9d853977
Unverified
Commit
9d853977
authored
Jul 22, 2020
by
Quan (Andy) Gan
Committed by
GitHub
Jul 22, 2020
Browse files
Deprecate old random walk implementations (#1846)
parent
41b905da
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
5 deletions
+23
-5
python/dgl/contrib/sampling/randomwalk.py
python/dgl/contrib/sampling/randomwalk.py
+23
-5
No files found.
python/dgl/contrib/sampling/randomwalk.py
View file @
9d853977
...
@@ -5,6 +5,7 @@ from ... import backend as F
...
@@ -5,6 +5,7 @@ from ... import backend as F
from
..._ffi.function
import
_init_api
from
..._ffi.function
import
_init_api
from
..._ffi.object
import
register_object
,
ObjectBase
from
..._ffi.object
import
register_object
,
ObjectBase
from
...
import
ndarray
from
...
import
ndarray
from
...base
import
dgl_warning
__all__
=
[
'random_walk'
,
__all__
=
[
'random_walk'
,
'random_walk_with_restart'
,
'random_walk_with_restart'
,
...
@@ -17,7 +18,9 @@ class RandomWalkTraces(ObjectBase):
...
@@ -17,7 +18,9 @@ class RandomWalkTraces(ObjectBase):
pass
pass
def
random_walk
(
g
,
seeds
,
num_traces
,
num_hops
):
def
random_walk
(
g
,
seeds
,
num_traces
,
num_hops
):
"""Batch-generate random walk traces on given graph with the same length.
"""**DEPRECATED**: please use :func:`dgl.sampling.random_walk` instead.
Batch-generate random walk traces on given graph with the same length.
Parameters
Parameters
----------
----------
...
@@ -39,6 +42,9 @@ def random_walk(g, seeds, num_traces, num_hops):
...
@@ -39,6 +42,9 @@ def random_walk(g, seeds, num_traces, num_hops):
traces[i, j, 0] are always starting nodes (i.e. seed[i]).
traces[i, j, 0] are always starting nodes (i.e. seed[i]).
"""
"""
dgl_warning
(
"This function is deprecated; please use dgl.sampling.random_walk instead"
,
DeprecationWarning
)
if
len
(
seeds
)
==
0
:
if
len
(
seeds
)
==
0
:
return
utils
.
toindex
([]).
tousertensor
()
return
utils
.
toindex
([]).
tousertensor
()
seeds
=
utils
.
toindex
(
seeds
).
todgltensor
()
seeds
=
utils
.
toindex
(
seeds
).
todgltensor
()
...
@@ -77,7 +83,9 @@ def _split_traces(traces):
...
@@ -77,7 +83,9 @@ def _split_traces(traces):
def
random_walk_with_restart
(
def
random_walk_with_restart
(
g
,
seeds
,
restart_prob
,
max_nodes_per_seed
,
g
,
seeds
,
restart_prob
,
max_nodes_per_seed
,
max_visit_counts
=
0
,
max_frequent_visited_nodes
=
0
):
max_visit_counts
=
0
,
max_frequent_visited_nodes
=
0
):
"""Batch-generate random walk traces on given graph with restart probability.
"""**DEPRECATED**: please use :func:`dgl.sampling.random_walk` instead.
Batch-generate random walk traces on given graph with restart probability.
Parameters
Parameters
----------
----------
...
@@ -109,6 +117,9 @@ def random_walk_with_restart(
...
@@ -109,6 +117,9 @@ def random_walk_with_restart(
---------
---------
[1] Eksombatchai et al., 2017 https://arxiv.org/abs/1711.07601
[1] Eksombatchai et al., 2017 https://arxiv.org/abs/1711.07601
"""
"""
dgl_warning
(
"This function is deprecated; please use dgl.sampling.random_walk instead"
,
DeprecationWarning
)
if
len
(
seeds
)
==
0
:
if
len
(
seeds
)
==
0
:
return
[]
return
[]
seeds
=
utils
.
toindex
(
seeds
).
todgltensor
()
seeds
=
utils
.
toindex
(
seeds
).
todgltensor
()
...
@@ -121,7 +132,9 @@ def random_walk_with_restart(
...
@@ -121,7 +132,9 @@ def random_walk_with_restart(
def
bipartite_single_sided_random_walk_with_restart
(
def
bipartite_single_sided_random_walk_with_restart
(
g
,
seeds
,
restart_prob
,
max_nodes_per_seed
,
g
,
seeds
,
restart_prob
,
max_nodes_per_seed
,
max_visit_counts
=
0
,
max_frequent_visited_nodes
=
0
):
max_visit_counts
=
0
,
max_frequent_visited_nodes
=
0
):
"""Batch-generate random walk traces on given graph with restart probability.
"""**DEPRECATED**: please use :func:`dgl.sampling.random_walk` instead.
Batch-generate random walk traces on given graph with restart probability.
The graph must be a bipartite graph.
The graph must be a bipartite graph.
...
@@ -161,6 +174,9 @@ def bipartite_single_sided_random_walk_with_restart(
...
@@ -161,6 +174,9 @@ def bipartite_single_sided_random_walk_with_restart(
---------
---------
[1] Eksombatchai et al., 2017 https://arxiv.org/abs/1711.07601
[1] Eksombatchai et al., 2017 https://arxiv.org/abs/1711.07601
"""
"""
dgl_warning
(
"This function is deprecated; please use dgl.sampling.random_walk instead"
,
DeprecationWarning
)
if
len
(
seeds
)
==
0
:
if
len
(
seeds
)
==
0
:
return
[]
return
[]
seeds
=
utils
.
toindex
(
seeds
).
todgltensor
()
seeds
=
utils
.
toindex
(
seeds
).
todgltensor
()
...
@@ -171,8 +187,7 @@ def bipartite_single_sided_random_walk_with_restart(
...
@@ -171,8 +187,7 @@ def bipartite_single_sided_random_walk_with_restart(
def
metapath_random_walk
(
hg
,
etypes
,
seeds
,
num_traces
):
def
metapath_random_walk
(
hg
,
etypes
,
seeds
,
num_traces
):
"""Generate random walk traces from an array of seed nodes (or starting nodes),
"""**DEPRECATED**: please use :func:`dgl.sampling.random_walk` instead.
based on the given metapath.
For a single seed node, ``num_traces`` traces would be generated. A trace would
For a single seed node, ``num_traces`` traces would be generated. A trace would
...
@@ -203,6 +218,9 @@ def metapath_random_walk(hg, etypes, seeds, num_traces):
...
@@ -203,6 +218,9 @@ def metapath_random_walk(hg, etypes, seeds, num_traces):
-----
-----
The traces does **not** include the seed nodes themselves.
The traces does **not** include the seed nodes themselves.
"""
"""
dgl_warning
(
"This function is deprecated; please use dgl.sampling.random_walk instead"
,
DeprecationWarning
)
if
len
(
etypes
)
==
0
:
if
len
(
etypes
)
==
0
:
raise
ValueError
(
'empty metapath'
)
raise
ValueError
(
'empty metapath'
)
if
hg
.
to_canonical_etype
(
etypes
[
0
])[
0
]
!=
hg
.
to_canonical_etype
(
etypes
[
-
1
])[
2
]:
if
hg
.
to_canonical_etype
(
etypes
[
0
])[
0
]
!=
hg
.
to_canonical_etype
(
etypes
[
-
1
])[
2
]:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment