torch_geometric.data.GraphStore

class GraphStore(edge_attr_cls: Optional[Any] = None)[source]

Bases: ABC

一个抽象基类,用于从远程图存储访问边。

Parameters:

edge_attr_cls (EdgeAttr, optional) – 用户定义的 EdgeAttr 类,用于自定义所需的属性及其顺序以唯一标识边。(默认值:None

put_edge_index(edge_index: Tuple[Tensor, Tensor], *args, **kwargs) bool[source]

Synchronously adds an edge_index tuple to the GraphStore. Returns whether insertion was successful.

Parameters:
Return type:

bool 翻译后的内容: bool 在这个例子中,`bool` 是一个Python函数名称,根据翻译规则1,不需要翻译。因此,翻译后的内容保持不变。

get_edge_index(*args, **kwargs) Tuple[Tensor, Tensor][source]

Synchronously obtains an edge_index tuple from the GraphStore.

Parameters:
  • *args – Arguments passed to EdgeAttr.

  • **kwargs – Keyword arguments passed to EdgeAttr.

Raises:

KeyError – If the edge_index corresponding to the input EdgeAttr was not found.

Return type:

Tuple[Tensor, Tensor]

remove_edge_index(*args, **kwargs) bool[source]

Synchronously deletes an edge_index tuple from the GraphStore. Returns whether deletion was successful.

Parameters:
  • *args – Arguments passed to EdgeAttr.

  • **kwargs – Keyword arguments passed to EdgeAttr.

Return type:

bool 翻译后的内容: bool 在这个例子中,`bool` 是一个Python函数名称,根据翻译规则1,不需要翻译。因此,翻译后的内容保持不变。

abstract get_all_edge_attrs() List[EdgeAttr][source]

返回所有已注册的边缘属性。

Return type:

List[EdgeAttr]

coo(edge_types: Optional[List[Any]] = None, store: bool = False) Tuple[Dict[Tuple[str, str, str], Tensor], Dict[Tuple[str, str, str], Tensor], Dict[Tuple[str, str, str], Optional[Tensor]]][source]

Returns the edge indices in the GraphStore in COO format.

Parameters:
  • edge_types (List[Any], optional) – The edge types of edge indices to obtain. If set to None, will return the edge indices of all existing edge types. (default: None)

  • store (bool, optional) – Whether to store converted edge indices in the GraphStore. (default: False)

Return type:

Tuple[Dict[Tuple[str, str, str], Tensor], Dict[Tuple[str, str, str], Tensor], Dict[Tuple[str, str, str], Optional[Tensor]]]

csr(edge_types: Optional[List[Any]] = None, store: bool = False) Tuple[Dict[Tuple[str, str, str], Tensor], Dict[Tuple[str, str, str], Tensor], Dict[Tuple[str, str, str], Optional[Tensor]]][source]

Returns the edge indices in the GraphStore in CSR format.

Parameters:
  • edge_types (List[Any], optional) – The edge types of edge indices to obtain. If set to None, will return the edge indices of all existing edge types. (default: None)

  • store (bool, optional) – Whether to store converted edge indices in the GraphStore. (default: False)

Return type:

Tuple[Dict[Tuple[str, str, str], Tensor], Dict[Tuple[str, str, str], Tensor], Dict[Tuple[str, str, str], Optional[Tensor]]]

csc(edge_types: Optional[List[Any]] = None, store: bool = False) Tuple[Dict[Tuple[str, str, str], Tensor], Dict[Tuple[str, str, str], Tensor], Dict[Tuple[str, str, str], Optional[Tensor]]][source]

Returns the edge indices in the GraphStore in CSC format.

Parameters:
  • edge_types (List[Any], optional) – The edge types of edge indices to obtain. If set to None, will return the edge indices of all existing edge types. (default: None)

  • store (bool, optional) – Whether to store converted edge indices in the GraphStore. (default: False)

Return type:

Tuple[Dict[Tuple[str, str, str], Tensor], Dict[Tuple[str, str, str], Tensor], Dict[Tuple[str, str, str], Optional[Tensor]]]