Unverified Commit 99a02f07 authored by yxy235's avatar yxy235 Committed by GitHub
Browse files

[GraphBolt] Update docstring of `SampledSubgraph`. (#6991)


Co-authored-by: default avatarUbuntu <ubuntu@ip-172-31-0-133.us-west-2.compute.internal>
parent 03ca11f5
...@@ -34,8 +34,31 @@ class SampledSubgraph: ...@@ -34,8 +34,31 @@ class SampledSubgraph:
`indptr` stores the index in the data array where each column `indptr` stores the index in the data array where each column
starts. `indices` stores the row indices of the non-zero elements. starts. `indices` stores the row indices of the non-zero elements.
- If `sampled_csc` is a dictionary: The keys should be edge type and - If `sampled_csc` is a dictionary: The keys should be edge type and
the values should be corresponding node pairs. The ids inside the values should be corresponding node pairs. The ids inside is
is heterogeneous ids.""" heterogeneous ids.
Examples
--------
1. Homogeneous graph.
>>> import dgl.graphbolt as gb
>>> import torch
>>> sampled_csc = gb.CSCFormatBase(
... indptr=torch.tensor([0, 1, 2, 3]),
... indices=torch.tensor([0, 1, 2]))
>>> print(sampled_csc)
CSCFormatBase(indptr=tensor([0, 1, 2, 3]),
indices=tensor([0, 1, 2]),
)
2. Heterogeneous graph.
sampled_csc = {"A:relation:B": gb.CSCFormatBase(
... indptr=torch.tensor([0, 1, 2, 3]),
... indices=torch.tensor([0, 1, 2]))}
>>> print(sampled_csc)
{'A:relation:B': CSCFormatBase(indptr=tensor([0, 1, 2, 3]),
indices=tensor([0, 1, 2]),
)}
"""
raise NotImplementedError raise NotImplementedError
@property @property
...@@ -46,8 +69,8 @@ class SampledSubgraph: ...@@ -46,8 +69,8 @@ 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 - If `original_column_node_ids` is a tensor: It represents the original
original node ids. 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.
...@@ -64,11 +87,11 @@ class SampledSubgraph: ...@@ -64,11 +87,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 - If `original_row_node_ids` is a tensor: It represents the original
original node ids. node ids.
- If `original_row_node_ids` is a dictionary: The keys should be - If `original_row_node_ids` is a dictionary: The keys should be node
node type and the values should be corresponding original type and the values should be corresponding original heterogeneous
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
...@@ -78,11 +101,11 @@ class SampledSubgraph: ...@@ -78,11 +101,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 - If `original_edge_ids` is a tensor: It represents the original edge
original edge ids. ids.
- If `original_edge_ids` is a dictionary: The keys should be - If `original_edge_ids` is a dictionary: The keys should be edge type
edge type and the values should be corresponding original and the values should be corresponding original heterogeneous edge
heterogeneous edge ids. ids.
""" """
return None return None
...@@ -105,12 +128,12 @@ class SampledSubgraph: ...@@ -105,12 +128,12 @@ class SampledSubgraph:
---------- ----------
self : SampledSubgraph self : SampledSubgraph
The sampled subgraph. The sampled subgraph.
edges : Union[Dict[str, Tuple[torch.Tensor, torch.Tensor]], edges : Union[Tuple[torch.Tensor, torch.Tensor],
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 dictionary sampled subgraph is heterogeneous, then `edges` should be a
of edge types and the corresponding edges to exclude. dictionary of edge types and the corresponding edges to exclude.
assume_num_node_within_int32: bool assume_num_node_within_int32: bool
If True, assumes the value of node IDs in the provided `edges` fall If True, assumes the value of node IDs in the provided `edges` fall
within the int32 range, which can significantly enhance computation within the int32 range, which can significantly enhance computation
......
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