torch_geometric.transforms.LargestConnectedComponents

class LargestConnectedComponents(num_components: int = 1, connection: str = 'weak')[source]

Bases: BaseTransform

Selects the subgraph that corresponds to the largest connected components in the graph (functional name: largest_connected_components).

Parameters:
  • num_components (int, optional) – Number of largest components to keep (default: 1)

  • connection (str, optional) – Type of connection to use for directed graphs, can be either 'strong' or 'weak'. Nodes i and j are strongly connected if a path exists both from i to j and from j to i. A directed graph is weakly connected if replacing all of its directed edges with undirected edges produces a connected (undirected) graph. (default: 'weak')