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
ced802d0
Unverified
Commit
ced802d0
authored
Jul 12, 2023
by
czkkkkkk
Committed by
GitHub
Jul 12, 2023
Browse files
[Graphbolot] Add the exclude edges interface (#5988)
parent
7c2ea23a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
5 deletions
+35
-5
python/dgl/graphbolt/impl/sampled_subgraph_impl.py
python/dgl/graphbolt/impl/sampled_subgraph_impl.py
+35
-5
No files found.
python/dgl/graphbolt/impl/sampled_subgraph_impl.py
View file @
ced802d0
...
@@ -37,13 +37,13 @@ class SampledSubgraphImpl(SampledSubgraph):
...
@@ -37,13 +37,13 @@ class SampledSubgraphImpl(SampledSubgraph):
{('A', 'B', 'relation'): tensor([19, 20, 21])}
{('A', 'B', 'relation'): tensor([19, 20, 21])}
"""
"""
node_pairs
:
Union
[
node_pairs
:
Union
[
Dict
[
Tuple
[
str
,
str
,
str
],
Tuple
[
torch
.
t
ensor
,
torch
.
t
ensor
]],
Dict
[
Tuple
[
str
,
str
,
str
],
Tuple
[
torch
.
T
ensor
,
torch
.
T
ensor
]],
Tuple
[
torch
.
t
ensor
,
torch
.
t
ensor
],
Tuple
[
torch
.
T
ensor
,
torch
.
T
ensor
],
]
=
None
]
=
None
reverse_column_node_ids
:
Union
[
Dict
[
str
,
torch
.
t
ensor
],
torch
.
t
ensor
]
=
None
reverse_column_node_ids
:
Union
[
Dict
[
str
,
torch
.
T
ensor
],
torch
.
T
ensor
]
=
None
reverse_row_node_ids
:
Union
[
Dict
[
str
,
torch
.
t
ensor
],
torch
.
t
ensor
]
=
None
reverse_row_node_ids
:
Union
[
Dict
[
str
,
torch
.
T
ensor
],
torch
.
T
ensor
]
=
None
reverse_edge_ids
:
Union
[
reverse_edge_ids
:
Union
[
Dict
[
Tuple
[
str
,
str
,
str
],
torch
.
t
ensor
],
torch
.
t
ensor
Dict
[
Tuple
[
str
,
str
,
str
],
torch
.
T
ensor
],
torch
.
T
ensor
]
=
None
]
=
None
def
__post_init__
(
self
):
def
__post_init__
(
self
):
...
@@ -68,3 +68,33 @@ class SampledSubgraphImpl(SampledSubgraph):
...
@@ -68,3 +68,33 @@ class SampledSubgraphImpl(SampledSubgraph):
assert
all
(
assert
all
(
isinstance
(
item
,
torch
.
Tensor
)
for
item
in
self
.
node_pairs
isinstance
(
item
,
torch
.
Tensor
)
for
item
in
self
.
node_pairs
),
"Nodes in pairs should be of type torch.Tensor."
),
"Nodes in pairs should be of type torch.Tensor."
def
exclude_edges
(
subgraph
:
SampledSubgraphImpl
,
edges
:
Union
[
Dict
[
Tuple
[
str
,
str
,
str
],
Tuple
[
torch
.
Tensor
,
torch
.
Tensor
]],
Tuple
[
torch
.
Tensor
,
torch
.
Tensor
],
],
)
->
SampledSubgraphImpl
:
r
"""Exclude edges from the sampled subgraph.
Parameters
----------
subgraph : SampledSubgraphImpl
The sampled subgraph.
edges : Union[Dict[Tuple[str, str, str], Tuple[torch.Tensor, torch.Tensor]],
Tuple[torch.Tensor, torch.Tensor]]
Edges to exclude. If sampled subgraph is homogeneous, then `edges`
should be a pair of tensors representing the edges to exclude. If
sampled subgraph is heterogeneous, then `edges` should be a dictionary
of edge types and the corresponding edges to exclude.
Returns
-------
SampledSubgraphImpl
The sampled subgraph with the excluded edges.
"""
# TODO(zhenkun): Implement this.
raise
NotImplementedError
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