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
a6d5a0cb
Unverified
Commit
a6d5a0cb
authored
Oct 28, 2019
by
Quan (Andy) Gan
Committed by
GitHub
Oct 28, 2019
Browse files
[BUG] Fix #717 (#946)
* [BUG] Fix #717 * fix mxnet test
parent
421b05e7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
1 deletion
+11
-1
python/dgl/subgraph.py
python/dgl/subgraph.py
+3
-1
tests/compute/test_subgraph.py
tests/compute/test_subgraph.py
+8
-0
No files found.
python/dgl/subgraph.py
View file @
a6d5a0cb
...
...
@@ -46,6 +46,7 @@ class DGLSubGraph(DGLGraph):
self
.
_parent
=
parent
self
.
_parent_nid
=
sgi
.
induced_nodes
self
.
_parent_eid
=
sgi
.
induced_edges
self
.
_subgraph_index
=
sgi
# override APIs
def
add_nodes
(
self
,
num
,
data
=
None
):
...
...
@@ -136,4 +137,5 @@ class DGLSubGraph(DGLGraph):
tensor
The node ID array in the subgraph.
"""
return
map_to_subgraph_nid
(
self
.
_graph
,
utils
.
toindex
(
parent_vids
)).
tousertensor
()
v
=
map_to_subgraph_nid
(
self
.
_subgraph_index
,
utils
.
toindex
(
parent_vids
))
return
v
.
tousertensor
()
tests/compute/test_subgraph.py
View file @
a6d5a0cb
...
...
@@ -76,6 +76,14 @@ def test_basics():
sg
.
ndata
[
'h'
]
=
F
.
zeros
((
6
,
D
))
assert
F
.
allclose
(
h
,
g
.
ndata
[
'h'
])
def
test_map_to_subgraph
():
g
=
DGLGraph
()
g
.
add_nodes
(
10
)
g
.
add_edges
(
F
.
arange
(
0
,
9
),
F
.
arange
(
1
,
10
))
h
=
g
.
subgraph
([
0
,
1
,
2
,
5
,
8
])
v
=
h
.
map_to_subgraph_nid
([
0
,
8
,
2
])
assert
np
.
array_equal
(
F
.
asnumpy
(
v
),
np
.
array
([
0
,
4
,
2
]))
def
test_merge
():
# FIXME: current impl cannot handle this case!!!
# comment out for now to test CI
...
...
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