statistics

Graph information statistics.

graph_datasets.utils.statistics.node_homo(adj: spmatrix, labels: Tensor) float[source]

Calculate node homophily.

Parameters:
  • adj (sp.spmatrix) – adjacent matrix.

  • labels (torch.Tensor) – labels.

Returns:

node homophily.

Return type:

float

graph_datasets.utils.statistics.edge_homo(adj: spmatrix, labels: Tensor) float[source]

Calculate edge homophily.

Parameters:
  • adj (sp.spmatrix) – adjacent matrix.

  • labels (torch.Tensor) – labels.

Returns:

edge homophily.

Return type:

float

graph_datasets.utils.statistics.statistics(graph: DGLGraph, labels: Tensor, dataset_name: str = '', h_1=True, h_2=True) dict[source]

Calculate homophily metrics of graphs.

Parameters:
  • graph (dgl.DGLGraph) – Graph

  • labels (torch.Tensor) – Labels

  • dataset_name (str, optional) – Dataset name. Defaults to ‘’.

  • h_1 (bool, optional) – 1-hop graph metrics. Defaults to True.

  • h_2 (bool, optional) – 2-hop graph metrics. Defaults to True.

Raises:

MemoryError – OOM.

Returns:

Dict of metric results.

Return type:

dict

common

Common utils.

graph_datasets.utils.common.tab_printer(args: Dict, thead: List[str] | None = None, cols_align: List[str] | None = None, cols_valign: List[str] | None = None, cols_dtype: List[str] | None = None, sort: bool = True) None[source]

Function to print the logs in a nice tabular format.

Parameters:
  • args (Dict) – value dict.

  • thead (List[str], optional) – table head. Defaults to None.

  • cols_align (List[str], optional) – horizontal alignment of the columns. Defaults to None.

  • cols_valign (List[str], optional) – vertical alignment of the columns. Defaults to None.

  • cols_dtype (List[str], optional) – value types of the columns. Defaults to None.

  • sort (bool, optional) – whether to sort the keys. Defaults to True.

Returns:

table string to print.

Return type:

str

graph_datasets.utils.common.download_from_google_drive(gid: str, output: str, quiet: bool = False, file_name: str | None = None) None[source]

Download data from google drive.

Parameters:
  • id (str) – Id for google drive url.

  • output (str) – Path to save data.

  • quiet (bool) – Suppress terminal output. Default is False.

  • file_name (str) – File name. Default to None.