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
625f8a6b
"docs/git@developer.sourcefind.cn:OpenDAS/bitsandbytes.git" did not exist on "bf0153812f3648c584b6698f5fa2e14c412a7be7"
Unverified
Commit
625f8a6b
authored
Oct 19, 2023
by
Mingbang Wang
Committed by
GitHub
Oct 19, 2023
Browse files
[GraphBolt] Modify `from_dglgraph()` (#6470)
parent
a6daf822
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
9 deletions
+13
-9
python/dgl/graphbolt/impl/csc_sampling_graph.py
python/dgl/graphbolt/impl/csc_sampling_graph.py
+12
-7
tests/python/pytorch/graphbolt/impl/test_csc_sampling_graph.py
.../python/pytorch/graphbolt/impl/test_csc_sampling_graph.py
+1
-2
No files found.
python/dgl/graphbolt/impl/csc_sampling_graph.py
View file @
625f8a6b
...
@@ -825,14 +825,19 @@ def from_dglgraph(
...
@@ -825,14 +825,19 @@ def from_dglgraph(
include_original_edge_id
:
bool
=
False
,
include_original_edge_id
:
bool
=
False
,
)
->
CSCSamplingGraph
:
)
->
CSCSamplingGraph
:
"""Convert a DGLGraph to CSCSamplingGraph."""
"""Convert a DGLGraph to CSCSamplingGraph."""
homo_g
,
ntype_count
,
_
=
to_homogeneous
(
g
,
return_count
=
True
)
homo_g
,
ntype_count
,
_
=
to_homogeneous
(
g
,
return_count
=
True
)
# Initialize metadata.
node_type_to_id
=
{
ntype
:
g
.
get_ntype_id
(
ntype
)
for
ntype
in
g
.
ntypes
}
if
is_homogeneous
:
edge_type_to_id
=
{
metadata
=
None
etype_tuple_to_str
(
etype
):
g
.
get_etype_id
(
etype
)
else
:
for
etype
in
g
.
canonical_etypes
# Initialize metadata.
}
node_type_to_id
=
{
ntype
:
g
.
get_ntype_id
(
ntype
)
for
ntype
in
g
.
ntypes
}
metadata
=
GraphMetadata
(
node_type_to_id
,
edge_type_to_id
)
edge_type_to_id
=
{
etype_tuple_to_str
(
etype
):
g
.
get_etype_id
(
etype
)
for
etype
in
g
.
canonical_etypes
}
metadata
=
GraphMetadata
(
node_type_to_id
,
edge_type_to_id
)
# Obtain CSC matrix.
# Obtain CSC matrix.
indptr
,
indices
,
edge_ids
=
homo_g
.
adj_tensors
(
"csc"
)
indptr
,
indices
,
edge_ids
=
homo_g
.
adj_tensors
(
"csc"
)
...
...
tests/python/pytorch/graphbolt/impl/test_csc_sampling_graph.py
View file @
625f8a6b
...
@@ -1321,8 +1321,7 @@ def test_from_dglgraph_homogeneous():
...
@@ -1321,8 +1321,7 @@ def test_from_dglgraph_homogeneous():
assert
gb_g
.
total_num_edges
==
dgl_g
.
num_edges
()
assert
gb_g
.
total_num_edges
==
dgl_g
.
num_edges
()
assert
torch
.
equal
(
gb_g
.
node_type_offset
,
torch
.
tensor
([
0
,
1000
]))
assert
torch
.
equal
(
gb_g
.
node_type_offset
,
torch
.
tensor
([
0
,
1000
]))
assert
gb_g
.
type_per_edge
is
None
assert
gb_g
.
type_per_edge
is
None
assert
gb_g
.
metadata
.
node_type_to_id
==
{
"_N"
:
0
}
assert
gb_g
.
metadata
is
None
assert
gb_g
.
metadata
.
edge_type_to_id
==
{
"_N:_E:_N"
:
0
}
@
unittest
.
skipIf
(
@
unittest
.
skipIf
(
...
...
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