torch_geometric_signed_directed.utils.general.extract_network

Functions

extract_network(→ Tuple[scipy.sparse.spmatrix, ...)

Find the largest connected component and iteratively only include nodes with degree at least lowest_degree,

Module Contents

extract_network(A: scipy.sparse.spmatrix, labels: numpy.array | torch.LongTensor | None = None, lowest_degree: int = 2, max_iter=10) Tuple[scipy.sparse.spmatrix, numpy.array]

Find the largest connected component and iteratively only include nodes with degree at least lowest_degree, for at most max_iter iterations, from the DIGRAC: Digraph Clustering Based on Flow Imbalance paper.

Arg types:
  • A (scipy sparse matrix) - Adjacency matrix.

  • labels (numpy array or torch.LongTensor, optional) - Node labels, default None.

  • lowest_degree (int, optional) - The lowest degree for the output network, default 2.

  • max_iter (int, optional) - The maximum number of iterations.

Return types:
  • A (scipy sparse matrix) - Adjacency matrix after fixing degrees and obtaining a connected netework.

  • labels (numpy array) - Node labels after fixing degrees and obtaining a connected netework.