topobench.data.utils package#

Init file for data/utils module.

data2simplicial(data)#

Convert a data dictionary into a SimplicialComplex object.

Parameters:
datadict

A dictionary containing at least ‘incidence_0’, ‘adjacency_0’, ‘incidence_1’, ‘incidence_2’, and optionally ‘incidence_3’ tensors.

Returns:
SimplicialComplex

A SimplicialComplex object constructed from nodes, edges, triangles, and tetrahedrons.

download_file_from_drive(file_link, path_to_save, dataset_name, file_format='tar.gz')#

Download a file from a Google Drive link and saves it to the specified path.

Parameters:
file_linkstr

The Google Drive link of the file to download.

path_to_savestr

The path where the downloaded file will be saved.

dataset_namestr

The name of the dataset.

file_formatstr, optional

The format of the downloaded file. Defaults to “tar.gz”.

Raises:
None
ensure_serializable(obj)#

Ensure that the object is serializable.

Parameters:
objobject

Object to ensure serializability.

Returns:
object

Object that is serializable.

generate_zero_sparse_connectivity(m, n)#

Generate a zero sparse connectivity matrix.

Parameters:
mint

Number of rows.

nint

Number of columns.

Returns:
torch.sparse_coo_tensor

Zero sparse connectivity matrix.

get_combinatorial_complex_connectivity(complex, max_rank, neighborhoods=None)#

Get the connectivity matrices for the Combinatorial Complex.

Parameters:
complextopnetx.CombinatorialComplex

Cell complex.

max_rankint

Maximum rank of the complex.

neighborhoodslist, optional

List of neighborhoods of interest.

Returns:
dict

Dictionary containing the connectivity matrices.

get_complex_connectivity(complex, max_rank, neighborhoods=None, signed=False)#

Get the connectivity matrices for the complex.

Parameters:
complextoponetx.CellComplex or toponetx.SimplicialComplex

Cell complex.

max_rankint

Maximum rank of the complex.

neighborhoodslist, optional

List of neighborhoods of interest.

signedbool, optional

If True, returns signed connectivity matrices.

Returns:
dict

Dictionary containing the connectivity matrices.

get_routes_from_neighborhoods(neighborhoods)#

Get the routes from the neighborhoods.

Combination of src_rank, dst_rank. ex: [[0, 0], [1, 0], [1, 1], [1, 1], [2, 1]].

Parameters:
neighborhoodslist

List of neighborhoods of interest.

Returns:
list

List of routes.

load_cell_complex_dataset(cfg)#

Load cell complex datasets.

Parameters:
cfgDictConfig

Configuration parameters.

load_coauthorship_hypergraph_splits(data, parameters, train_prop=0.5)#

Load the split generated by rand_train_test_idx function.

Parameters:
datatorch_geometric.data.Data

Graph dataset.

parametersDictConfig

Configuration parameters.

train_propfloat

Proportion of training data.

Returns:
torch_geometric.data.Data:

Graph dataset with the specified split.

load_hypergraph_content_dataset(data_dir, data_name)#

Load hypergraph datasets from pickle files.

Parameters:
data_dirstr

Path to data.

data_namestr

Name of the dataset.

Returns:
torch_geometric.data.Data

Hypergraph dataset.

load_hypergraph_pickle_dataset(data_dir, data_name)#

Load hypergraph datasets from pickle files.

Parameters:
data_dirstr

Path to data.

data_namestr

Name of the dataset.

Returns:
torch_geometric.data.Data

Hypergraph dataset.

load_inductive_splits(dataset, parameters)#

Load multiple-graph datasets with the specified split.

Parameters:
datasettorch_geometric.data.Dataset

Graph dataset.

parametersDictConfig

Configuration parameters.

Returns:
list:

List containing the train, validation, and test splits.

load_manual_graph()#

Create a manual graph for testing purposes.

Returns:
torch_geometric.data.Data

Manual graph.

load_simplicial_dataset(cfg)#

Load simplicial datasets.

Parameters:
cfgDictConfig

Configuration parameters.

Returns:
torch_geometric.data.Data

Simplicial dataset.

load_transductive_splits(dataset, parameters)#

Load the graph dataset with the specified split.

Parameters:
datasettorch_geometric.data.Dataset

Graph dataset.

parametersDictConfig

Configuration parameters.

Returns:
list:

List containing the train, validation, and test splits.

make_hash(o)#

Make a hash from a dictionary, list, tuple or set to any level, that contains only other hashable types.

Parameters:
odict, list, tuple, set

Object to hash.

Returns:
int

Hash of the object.

read_us_county_demos(path, year=2012, y_col='Election')#

Load US County Demos dataset.

Parameters:
pathstr

Path to the dataset.

yearint, optional

Year to load the features (default: 2012).

y_colstr, optional

Column to use as label. Can be one of [‘Election’, ‘MedianIncome’, ‘MigraRate’, ‘BirthRate’, ‘DeathRate’, ‘BachelorRate’, ‘UnemploymentRate’] (default: “Election”).

Returns:
torch_geometric.data.Data

Data object of the graph for the US County Demos dataset.

select_neighborhoods_of_interest(connectivity, neighborhoods)#

Select the neighborhoods of interest.

Parameters:
connectivitydict

Connectivity matrices generated by default.

neighborhoodslist

List of neighborhoods of interest.

Returns:
dict

Connectivity matrices of interest.

Submodules#