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
7b972981
"src/rpc/network/socket_communicator.h" did not exist on "5d494c620757c2f4c1c70e735da892f11bef32c9"
Unverified
Commit
7b972981
authored
Oct 17, 2020
by
Quan (Andy) Gan
Committed by
GitHub
Oct 17, 2020
Browse files
fix bug in flatten and is_unibipartite (#2279)
parent
cbbbbde7
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
8 deletions
+20
-8
src/graph/heterograph_capi.cc
src/graph/heterograph_capi.cc
+13
-8
tests/compute/test_heterograph.py
tests/compute/test_heterograph.py
+7
-0
No files found.
src/graph/heterograph_capi.cc
View file @
7b972981
...
@@ -656,25 +656,30 @@ DGL_REGISTER_GLOBAL("transform._CAPI_DGLAsImmutableGraph")
...
@@ -656,25 +656,30 @@ DGL_REGISTER_GLOBAL("transform._CAPI_DGLAsImmutableGraph")
DGL_REGISTER_GLOBAL
(
"heterograph._CAPI_DGLFindSrcDstNtypes"
)
DGL_REGISTER_GLOBAL
(
"heterograph._CAPI_DGLFindSrcDstNtypes"
)
.
set_body
([]
(
DGLArgs
args
,
DGLRetValue
*
rv
)
{
.
set_body
([]
(
DGLArgs
args
,
DGLRetValue
*
rv
)
{
GraphRef
metagraph
=
args
[
0
];
GraphRef
metagraph
=
args
[
0
];
std
::
set
<
int64_t
>
dst_set
;
std
::
unordered_
set
<
int64_t
>
dst_set
;
std
::
set
<
int64_t
>
src_set
;
std
::
unordered_
set
<
int64_t
>
src_set
;
for
(
int64_t
eid
=
0
;
eid
<
metagraph
->
NumEdges
();
++
eid
)
{
for
(
int64_t
eid
=
0
;
eid
<
metagraph
->
NumEdges
();
++
eid
)
{
auto
edge
=
metagraph
->
FindEdge
(
eid
);
auto
edge
=
metagraph
->
FindEdge
(
eid
);
auto
src
=
edge
.
first
;
auto
src
=
edge
.
first
;
auto
dst
=
edge
.
second
;
auto
dst
=
edge
.
second
;
dst_set
.
insert
(
dst
);
dst_set
.
insert
(
dst
);
if
(
dst_set
.
count
(
src
))
src_set
.
insert
(
src
);
return
;
}
}
List
<
Value
>
srclist
,
dstlist
;
List
<
Value
>
srclist
,
dstlist
;
List
<
List
<
Value
>>
ret_list
;
List
<
List
<
Value
>>
ret_list
;
for
(
auto
dst
:
dst_set
)
for
(
int64_t
nid
=
0
;
nid
<
metagraph
->
NumVertices
();
++
nid
)
{
dstlist
.
push_back
(
Value
(
MakeValue
(
dst
)));
auto
is_dst
=
dst_set
.
count
(
nid
);
for
(
int64_t
nid
=
0
;
nid
<
metagraph
->
NumVertices
();
++
nid
)
auto
is_src
=
src_set
.
count
(
nid
);
if
(
!
dst_set
.
count
(
nid
))
if
(
is_dst
&&
is_src
)
return
;
else
if
(
is_dst
)
dstlist
.
push_back
(
Value
(
MakeValue
(
nid
)));
else
// If a node type is isolated, put it in srctype as defined in the Python docstring.
srclist
.
push_back
(
Value
(
MakeValue
(
nid
)));
srclist
.
push_back
(
Value
(
MakeValue
(
nid
)));
}
ret_list
.
push_back
(
srclist
);
ret_list
.
push_back
(
srclist
);
ret_list
.
push_back
(
dstlist
);
ret_list
.
push_back
(
dstlist
);
*
rv
=
ret_list
;
*
rv
=
ret_list
;
...
...
tests/compute/test_heterograph.py
View file @
7b972981
...
@@ -1736,6 +1736,13 @@ def test_bipartite(idtype):
...
@@ -1736,6 +1736,13 @@ def test_bipartite(idtype):
},
idtype
=
idtype
,
device
=
F
.
ctx
())
},
idtype
=
idtype
,
device
=
F
.
ctx
())
assert
not
g3
.
is_unibipartite
assert
not
g3
.
is_unibipartite
g4
=
dgl
.
heterograph
({
(
'A'
,
'AB'
,
'B'
):
([
0
,
0
,
1
],
[
1
,
2
,
5
]),
(
'C'
,
'CA'
,
'A'
):
([
1
,
0
],
[
0
,
0
])
},
idtype
=
idtype
,
device
=
F
.
ctx
())
assert
not
g4
.
is_unibipartite
@
parametrize_dtype
@
parametrize_dtype
def
test_dtype_cast
(
idtype
):
def
test_dtype_cast
(
idtype
):
g
=
dgl
.
graph
(([
0
,
1
,
0
,
2
],
[
0
,
1
,
1
,
0
]),
idtype
=
idtype
,
device
=
F
.
ctx
())
g
=
dgl
.
graph
(([
0
,
1
,
0
,
2
],
[
0
,
1
,
1
,
0
]),
idtype
=
idtype
,
device
=
F
.
ctx
())
...
...
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