"git@developer.sourcefind.cn:renzhc/diffusers_dcu.git" did not exist on "f861cde14f168ee3da391ed423d411968b456b9d"
Unverified Commit d3176272 authored by yxy235's avatar yxy235 Committed by GitHub
Browse files

[GraphBolt] Update docstring of sampled subgraph. (#6998)


Co-authored-by: default avatarUbuntu <ubuntu@ip-172-31-0-133.us-west-2.compute.internal>
Co-authored-by: default avatarHongzhi (Steve), Chen <chenhongzhi.nkcs@gmail.com>
parent 56b6a4eb
...@@ -30,16 +30,18 @@ class SampledSubgraph: ...@@ -30,16 +30,18 @@ class SampledSubgraph:
self, self,
) -> Union[CSCFormatBase, Dict[str, CSCFormatBase],]: ) -> Union[CSCFormatBase, Dict[str, CSCFormatBase],]:
"""Returns the node pairs representing edges in csc format. """Returns the node pairs representing edges in csc format.
- If `sampled_csc` is a CSCFormatBase: It should be in the csc format. - If `sampled_csc` is a CSCFormatBase: It should be in the csc
`indptr` stores the index in the data array where each column format. `indptr` stores the index in the data array where each
starts. `indices` stores the row indices of the non-zero elements. column starts. `indices` stores the row indices of the non-zero
- If `sampled_csc` is a dictionary: The keys should be edge type and elements.
the values should be corresponding node pairs. The ids inside is - If `sampled_csc` is a dictionary: The keys should be edge type and
heterogeneous ids. the values should be corresponding node pairs. The ids inside is
heterogeneous ids.
Examples Examples
-------- --------
1. Homogeneous graph. 1. Homogeneous graph.
>>> import dgl.graphbolt as gb >>> import dgl.graphbolt as gb
>>> import torch >>> import torch
>>> sampled_csc = gb.CSCFormatBase( >>> sampled_csc = gb.CSCFormatBase(
...@@ -51,6 +53,7 @@ class SampledSubgraph: ...@@ -51,6 +53,7 @@ class SampledSubgraph:
) )
2. Heterogeneous graph. 2. Heterogeneous graph.
sampled_csc = {"A:relation:B": gb.CSCFormatBase( sampled_csc = {"A:relation:B": gb.CSCFormatBase(
... indptr=torch.tensor([0, 1, 2, 3]), ... indptr=torch.tensor([0, 1, 2, 3]),
... indices=torch.tensor([0, 1, 2]))} ... indices=torch.tensor([0, 1, 2]))}
...@@ -69,11 +72,11 @@ class SampledSubgraph: ...@@ -69,11 +72,11 @@ class SampledSubgraph:
Column's reverse node ids in the original graph. A graph structure Column's reverse node ids in the original graph. A graph structure
can be treated as a coordinated row and column pair, and this is can be treated as a coordinated row and column pair, and this is
the mapped ids of the column. the mapped ids of the column.
- If `original_column_node_ids` is a tensor: It represents the original - If `original_column_node_ids` is a tensor: It represents the
node ids. original node ids.
- If `original_column_node_ids` is a dictionary: The keys should be - If `original_column_node_ids` is a dictionary: The keys should be
node type and the values should be corresponding original node type and the values should be corresponding original
heterogeneous node ids. heterogeneous node ids.
If present, it means column IDs are compacted, and `sampled_csc` If present, it means column IDs are compacted, and `sampled_csc`
column IDs match these compacted ones. column IDs match these compacted ones.
""" """
...@@ -87,11 +90,11 @@ class SampledSubgraph: ...@@ -87,11 +90,11 @@ class SampledSubgraph:
Row's reverse node ids in the original graph. A graph structure Row's reverse node ids in the original graph. A graph structure
can be treated as a coordinated row and column pair, and this is can be treated as a coordinated row and column pair, and this is
the mapped ids of the row. the mapped ids of the row.
- If `original_row_node_ids` is a tensor: It represents the original - If `original_row_node_ids` is a tensor: It represents the original
node ids. node ids.
- If `original_row_node_ids` is a dictionary: The keys should be node - If `original_row_node_ids` is a dictionary: The keys should be node
type and the values should be corresponding original heterogeneous type and the values should be corresponding original heterogeneous
node ids. node ids.
If present, it means row IDs are compacted, and `sampled_csc` If present, it means row IDs are compacted, and `sampled_csc`
row IDs match these compacted ones.""" row IDs match these compacted ones."""
return None return None
...@@ -101,11 +104,11 @@ class SampledSubgraph: ...@@ -101,11 +104,11 @@ class SampledSubgraph:
"""Returns corresponding reverse edge ids the original graph. """Returns corresponding reverse edge ids the original graph.
Reverse edge ids in the original graph. This is useful when edge Reverse edge ids in the original graph. This is useful when edge
features are needed. features are needed.
- If `original_edge_ids` is a tensor: It represents the original edge - If `original_edge_ids` is a tensor: It represents the original edge
ids. ids.
- If `original_edge_ids` is a dictionary: The keys should be edge type - If `original_edge_ids` is a dictionary: The keys should be edge
and the values should be corresponding original heterogeneous edge type and the values should be corresponding original heterogeneous
ids. edge ids.
""" """
return None return None
...@@ -119,17 +122,17 @@ class SampledSubgraph: ...@@ -119,17 +122,17 @@ class SampledSubgraph:
): ):
r"""Exclude edges from the sampled subgraph. r"""Exclude edges from the sampled subgraph.
This function can be used with sampled subgraphs, regardless of whether they This function can be used with sampled subgraphs, regardless of
have compacted row/column nodes or not. If the original subgraph has whether they have compacted row/column nodes or not. If the original
compacted row or column nodes, the corresponding row or column nodes in the subgraph has compacted row or column nodes, the corresponding row or
returned subgraph will also be compacted. column nodes in the returned subgraph will also be compacted.
Parameters Parameters
---------- ----------
self : SampledSubgraph self : SampledSubgraph
The sampled subgraph. The sampled subgraph.
edges : Union[Tuple[torch.Tensor, torch.Tensor], edges : Union[Tuple[torch.Tensor, torch.Tensor],
Dict[str, Tuple[torch.Tensor, torch.Tensor]]] Dict[str, Tuple[torch.Tensor, torch.Tensor]]]
Edges to exclude. If sampled subgraph is homogeneous, then `edges` Edges to exclude. If sampled subgraph is homogeneous, then `edges`
should be a pair of tensors representing the edges to exclude. If should be a pair of tensors representing the edges to exclude. If
sampled subgraph is heterogeneous, then `edges` should be a sampled subgraph is heterogeneous, then `edges` should be a
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment