topobench.transforms.data_manipulations.keep_only_connected_component module#

KeepOnlyConnectedComponent class definition.

class KeepOnlyConnectedComponent(**kwargs)#

Bases: BaseTransform

Class to keep only the largest connected components of the input graph.

Parameters:
**kwargsoptional

Parameters for the base transform.

__init__(**kwargs)#
forward(data)#

Apply the transform to the input data.

Parameters:
datatorch_geometric.data.Data

The input data.

Returns:
torch_geometric.data.Data

The transformed data.

class LargestConnectedComponents(num_components=1, connection='weak')#

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')

__init__(num_components=1, connection='weak')#
forward(data)#