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
3d854a6b
Unverified
Commit
3d854a6b
authored
Feb 04, 2024
by
Mingbang Wang
Committed by
GitHub
Feb 04, 2024
Browse files
[Misc] Correct docstrings in `python/dgl/convert.py` (#7060)
parent
6459a688
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
4 deletions
+5
-4
python/dgl/convert.py
python/dgl/convert.py
+5
-4
No files found.
python/dgl/convert.py
View file @
3d854a6b
"""Module for converting graph from/to other object."""
"""Module for converting graph from/to other object."""
from
collections
import
defaultdict
from
collections
import
defaultdict
from
collections.abc
import
Mapping
from
collections.abc
import
Mapping
...
@@ -296,9 +297,9 @@ def heterograph(data_dict, num_nodes_dict=None, idtype=None, device=None):
...
@@ -296,9 +297,9 @@ def heterograph(data_dict, num_nodes_dict=None, idtype=None, device=None):
>>> g = dgl.heterograph(data_dict)
>>> g = dgl.heterograph(data_dict)
>>> g
>>> g
Graph(num_nodes={'game': 5, 'topic': 3, 'user': 4},
Graph(num_nodes={'game': 5, 'topic': 3, 'user': 4},
num_edges={('user', 'follows', '
user
'): 2, ('user', 'follows', '
topic
'): 2,
num_edges={('user', 'follows', '
topic
'): 2, ('user', 'follows', '
user
'): 2,
('user', 'plays', 'game'): 2},
('user', 'plays', 'game'): 2},
metagraph=[('user', '
user
', 'follows'), ('user', '
topic
', 'follows'),
metagraph=[('user', '
topic
', 'follows'), ('user', '
user
', 'follows'),
('user', 'game', 'plays')])
('user', 'game', 'plays')])
Explicitly specify the number of nodes for each node type in the graph.
Explicitly specify the number of nodes for each node type in the graph.
...
@@ -1810,11 +1811,11 @@ def to_networkx(
...
@@ -1810,11 +1811,11 @@ def to_networkx(
... ('user', 'follows', 'topic'): (torch.tensor([1, 1]), torch.tensor([1, 2])),
... ('user', 'follows', 'topic'): (torch.tensor([1, 1]), torch.tensor([1, 2])),
... ('user', 'plays', 'game'): (torch.tensor([0, 3]), torch.tensor([3, 4]))
... ('user', 'plays', 'game'): (torch.tensor([0, 3]), torch.tensor([3, 4]))
... })
... })
...
g.ndata['n'] = {
>>>
g.ndata['n'] = {
... 'game': torch.zeros(5, 1),
... 'game': torch.zeros(5, 1),
... 'user': torch.ones(4, 1)
... 'user': torch.ones(4, 1)
... }
... }
...
g.edata['e'] = {
>>>
g.edata['e'] = {
... ('user', 'follows', 'user'): torch.zeros(2, 1),
... ('user', 'follows', 'user'): torch.zeros(2, 1),
... 'plays': torch.ones(2, 1)
... 'plays': torch.ones(2, 1)
... }
... }
...
...
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