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
32ea1b20
"docs/source/faqs.mdx" did not exist on "ecf51cb6786a75355a51fb98a643f47d25e48bd0"
Unverified
Commit
32ea1b20
authored
Jun 23, 2020
by
Quan (Andy) Gan
Committed by
GitHub
Jun 23, 2020
Browse files
remove edge list creation (#1688)
parent
7afd1d0d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
12 deletions
+4
-12
tutorials/basics/2_basics.py
tutorials/basics/2_basics.py
+0
-4
tutorials/basics/5_hetero.py
tutorials/basics/5_hetero.py
+4
-8
No files found.
tutorials/basics/2_basics.py
View file @
32ea1b20
...
...
@@ -69,10 +69,6 @@ start2 = dgl.DGLGraph((0, v))
adj
=
spp
.
coo_matrix
((
np
.
ones
(
len
(
u
)),
(
u
.
numpy
(),
v
.
numpy
())))
star3
=
dgl
.
DGLGraph
(
adj
)
# Create the same graph from a list of integer pairs.
elist
=
[(
0
,
1
),
(
0
,
2
),
(
0
,
3
),
(
0
,
4
),
(
0
,
5
)]
star4
=
dgl
.
DGLGraph
(
elist
)
###############################################################################
# You can also create a graph by progressively adding more nodes and edges.
# Although it is not as efficient as the above constructors, it is suitable
...
...
tutorials/basics/5_hetero.py
View file @
32ea1b20
...
...
@@ -96,14 +96,15 @@ using the heterograph class and its associated API.
#
# For instance, the following code creates the user-item interactions heterograph shown earlier.
# Each value of the dictionary is a
list of edge tuple
s.
# Each value of the dictionary is a
pair of source and destination array
s.
# Nodes are integer IDs starting from zero. Nodes IDs of different types have
# separate countings.
import
dgl
import
numpy
as
np
ratings
=
dgl
.
heterograph
(
{(
'user'
,
'+1'
,
'movie'
)
:
[(
0
,
0
)
,
(
0
,
1
),
(
1
,
0
)
],
(
'user'
,
'-1'
,
'movie'
)
:
[(
2
,
1
)]
})
{(
'user'
,
'+1'
,
'movie'
)
:
(
np
.
array
([
0
,
0
,
1
]
),
np
.
array
([
0
,
1
,
0
]
))
,
(
'user'
,
'-1'
,
'movie'
)
:
(
np
.
array
([
2
]),
np
.
array
([
1
]))
})
###############################################################################
# DGL supports creating a graph from a variety of data sources. The following
...
...
@@ -130,11 +131,6 @@ ratings = dgl.heterograph(
{(
'user'
,
'+1'
,
'movie'
)
:
plus1
,
(
'user'
,
'-1'
,
'movie'
)
:
minus1
})
# Creating from edge indices
ratings
=
dgl
.
heterograph
(
{(
'user'
,
'+1'
,
'movie'
)
:
([
0
,
0
,
1
],
[
0
,
1
,
0
]),
(
'user'
,
'-1'
,
'movie'
)
:
([
2
],
[
1
])})
###############################################################################
# Manipulating heterograph
# ------------------------
...
...
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