pytspl.io
IO module for reading data defined over a network.
Subpackages
Submodules
Functions
|
List the available datasets. |
|
Load the dataset and return the simplicial complex |
|
Read the B1 and B2 incidence matrices. |
|
Read a csv file and returns a graph. |
|
Read a tntp file and returns a graph. |
|
Generate a random simplicial complex. |
Package Contents
- pytspl.io.list_datasets() list[source]
List the available datasets.
- Returns:
list: The list of available datasets.
- pytspl.io.load_dataset(dataset: str) tuple[source]
Load the dataset and return the simplicial complex and coordinates.
- Args:
dataset (str): The name of the dataset.
- ValueError:
If the dataset is not found.
- Returns:
SimplicialComplex: The simplicial complex of the dataset. dict: The coordinates of the nodes. If the coordinates do not exist, the coordinates are generated using spring layout. dict: The flow data of the dataset. If the flow data does not exist, an empty dictionary is returned.
- pytspl.io.read_B1_B2(B1_filename: str, B2_filename: str) tuple[source]
Read the B1 and B2 incidence matrices.
- Args:
B1_filename (str): The name of the B1 incidence matrix file. B2_filename (str): The name of the B2 incidence matrix file.
- Returns:
SCBuilder: SC builder object to build the simplicial complex. list: List of triangles (2-simplices).
- pytspl.io.read_csv(filename: str, delimiter: str, src_col: str, dest_col: str, feature_cols: list = None, start_index_zero: bool = True) pytspl.simplicial_complex.scbuilder.SCBuilder[source]
Read a csv file and returns a graph.
- Args:
filename (str): The name of the csv file. delimiter (str): The delimiter used in the csv file. src_col (str): The name of the column containing the source nodes. dest_col (str): The name of the column containing the destination nodes. feature_cols (list, optional): The names of the feature columns. Defaults to None. start_index_zero (bool): True, if the node ids start from 0. False,
- Returns:
SCBuilder: SC builder object to build the simplicial complex.
- pytspl.io.read_tntp(filename: str, src_col: str, dest_col: str, skip_rows: int, delimiter: str = '\t', start_index_zero: bool = True) pytspl.simplicial_complex.scbuilder.SCBuilder[source]
Read a tntp file and returns a graph.
- Args:
filename (str): The name of the tntp file. src_col (str): The name of the column containing the source nodes. dest_col (str): The name of the column containing the destination nodes. skip_rows (int): The number of (metadata) rows to skip in the tntp file. delimiter (str): The delimiter used in the tntp file. Defaults to next line. start_index_zero (bool): True, if the node ids start from 0. False, if the node ids start from 1.
- Returns:
SCBuilder: SC builder object to build the simplicial complex.
- pytspl.io.generate_random_simplicial_complex(num_of_nodes: int, p: float, dist_threshold: float, seed: int) tuple[source]
Generate a random simplicial complex.
- Args:
num_of_nodes (int): Number of nodes in the graph. p (float): Probability of edge creation. dist_threshold (float): Threshold for simplicial complex construction. seed (int): Seed for random number generator.
- Returns:
SimplicialComplex: The generated simplicial complex. dict: The coordinates of the nodes.