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
4c5489e8
"vscode:/vscode.git/clone" did not exist on "1ed61e4b2ec2e33ac6cada0729cf49e5aaefe6a6"
Unverified
Commit
4c5489e8
authored
Aug 28, 2023
by
Rhett Ying
Committed by
GitHub
Aug 28, 2023
Browse files
[GraphBolt] remove duplicate test utils (#6220)
parent
bc72349c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
58 deletions
+0
-58
tests/python/pytorch/graphbolt/impl/gb_test_utils.py
tests/python/pytorch/graphbolt/impl/gb_test_utils.py
+0
-58
No files found.
tests/python/pytorch/graphbolt/impl/gb_test_utils.py
deleted
100644 → 0
View file @
bc72349c
import
dgl.graphbolt
as
gb
import
scipy.sparse
as
sp
import
torch
def
rand_csc_graph
(
N
,
density
):
adj
=
sp
.
random
(
N
,
N
,
density
)
adj
=
adj
+
adj
.
T
adj
=
adj
.
tocsc
()
indptr
=
torch
.
LongTensor
(
adj
.
indptr
)
indices
=
torch
.
LongTensor
(
adj
.
indices
)
graph
=
gb
.
from_csc
(
indptr
,
indices
)
return
graph
def
random_homo_graph
(
num_nodes
,
num_edges
):
csc_indptr
=
torch
.
randint
(
0
,
num_edges
,
(
num_nodes
+
1
,))
csc_indptr
=
torch
.
sort
(
csc_indptr
)[
0
]
csc_indptr
[
0
]
=
0
csc_indptr
[
-
1
]
=
num_edges
indices
=
torch
.
randint
(
0
,
num_nodes
,
(
num_edges
,))
return
csc_indptr
,
indices
def
get_metadata
(
num_ntypes
,
num_etypes
):
ntypes
=
{
f
"n
{
i
}
"
:
i
for
i
in
range
(
num_ntypes
)}
etypes
=
{}
count
=
0
for
n1
in
range
(
num_ntypes
):
for
n2
in
range
(
n1
,
num_ntypes
):
if
count
>=
num_etypes
:
break
etypes
.
update
({(
f
"n
{
n1
}
"
,
f
"e
{
count
}
"
,
f
"n
{
n2
}
"
):
count
})
count
+=
1
return
gb
.
GraphMetadata
(
ntypes
,
etypes
)
def
random_hetero_graph
(
num_nodes
,
num_edges
,
num_ntypes
,
num_etypes
):
csc_indptr
,
indices
=
random_homo_graph
(
num_nodes
,
num_edges
)
metadata
=
get_metadata
(
num_ntypes
,
num_etypes
)
# Randomly get node type split point.
node_type_offset
=
torch
.
sort
(
torch
.
randint
(
0
,
num_nodes
,
(
num_ntypes
+
1
,))
)[
0
]
node_type_offset
[
0
]
=
0
node_type_offset
[
-
1
]
=
num_nodes
type_per_edge
=
[]
for
i
in
range
(
num_nodes
):
num
=
csc_indptr
[
i
+
1
]
-
csc_indptr
[
i
]
type_per_edge
.
append
(
torch
.
sort
(
torch
.
randint
(
0
,
num_etypes
,
(
num
,)))[
0
]
)
type_per_edge
=
torch
.
cat
(
type_per_edge
,
dim
=
0
)
return
(
csc_indptr
,
indices
,
node_type_offset
,
type_per_edge
,
metadata
)
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