topobench.transforms.liftings.graph2simplicial package#

Submodules#

topobench.transforms.liftings.graph2simplicial.base module#

Abstract class for lifting graphs to simplicial complexes.

class topobench.transforms.liftings.graph2simplicial.base.Graph2SimplicialLifting(complex_dim=2, **kwargs)[source]#

Bases: GraphLifting

Abstract class for lifting graphs to simplicial complexes.

Parameters:
complex_dimint, optional

The maximum dimension of the simplicial complex to be generated. Default is 2.

**kwargsoptional

Additional arguments for the class.

topobench.transforms.liftings.graph2simplicial.clique_lifting module#

This module implements the CliqueLifting class, which lifts graphs to simplicial complexes.

class topobench.transforms.liftings.graph2simplicial.clique_lifting.SimplicialCliqueLifting(**kwargs)[source]#

Bases: Graph2SimplicialLifting

Lift graphs to simplicial complex domain.

The algorithm creates simplices by identifying the cliques and considering them as simplices of the same dimension.

Parameters:
**kwargsoptional

Additional arguments for the class.

lift_topology(data: Data) dict[source]#

Lift the topology of a graph to a simplicial complex.

Parameters:
datatorch_geometric.data.Data

The input data to be lifted.

Returns:
dict

The lifted topology.

topobench.transforms.liftings.graph2simplicial.dnd_lifting module#

Simulates a Dungeons & Dragons inspired system to lift graphs to simplicial complexes.

class topobench.transforms.liftings.graph2simplicial.dnd_lifting.SimplicialDnDLifting(**kwargs)[source]#

Bases: Graph2SimplicialLifting

Lift graphs to simplicial complex domain using a Dungeons & Dragons inspired system.

Parameters:
**kwargsoptional

Additional arguments for the class.

lift_topology(data: Data, max_simplices=10) dict[source]#

Lift the topology of a graph to a simplicial complex using Dungeons & Dragons (D&D) inspired mechanics.

Parameters:
dataData

The input data to be lifted.

max_simplicesint

Maximum number of simplices to add for each node attribute.

Returns:
dict

The lifted topology.

topobench.transforms.liftings.graph2simplicial.eccentricity_lifting module#

This module implements the SimplicialEccentricityLifting class, which lifts graphs to simplicial complexes.

class topobench.transforms.liftings.graph2simplicial.eccentricity_lifting.SimplicialEccentricityLifting(**kwargs)[source]#

Bases: Graph2SimplicialLifting

Lift graphs to simplicial complex domain using eccentricity.

Parameters:
**kwargsoptional

Additional arguments for the class.

lift_topology(data: Data) dict[source]#

Lift the topology of a graph to a simplicial complex by identifying connected subgraphs as simplices.

Parameters:
datatorch_geometric.data.Data

The input data to be lifted.

Returns:
dict

The lifted topology.

topobench.transforms.liftings.graph2simplicial.graph_induced_lifting module#

This module implements the SimplicialGraphInducedLifting class, which lifts graphs to simplicial complexes.

class topobench.transforms.liftings.graph2simplicial.graph_induced_lifting.SimplicialGraphInducedLifting(**kwargs)[source]#

Bases: Graph2SimplicialLifting

Lift graphs to simplicial complex domain by identifying connected subgraphs as simplices.

Parameters:
**kwargsoptional

Additional arguments for the class.

lift_topology(data: Data) dict[source]#

Lift the topology of a graph to a simplicial complex by identifying connected subgraphs as simplices.

Parameters:
datatorch_geometric.data.Data

The input data to be lifted.

Returns:
dict

The lifted topology.

topobench.transforms.liftings.graph2simplicial.khop_lifting module#

This module implements the k-hop lifting of graphs to simplicial complexes.

class topobench.transforms.liftings.graph2simplicial.khop_lifting.SimplicialKHopLifting(max_k_simplices=25, **kwargs)[source]#

Bases: Graph2SimplicialLifting

Lift graphs to simplicial complex domain.

The function lifts a graph to a simplicial complex by considering k-hop neighborhoods. For each node its neighborhood is selected and then all the possible simplices, when considering the neighborhood as a clique, are added to the simplicial complex. For this reason this lifting does not conserve the initial graph topology.

Parameters:
max_k_simplicesint, optional

The maximum number of k-simplices to consider. Default is 25.

**kwargsoptional

Additional arguments for the class.

lift_topology(data: Data) dict[source]#

Lift the topology to simplicial complex domain.

Parameters:
datatorch_geometric.data.Data

The input data to be lifted.

Returns:
dict

The lifted topology.

topobench.transforms.liftings.graph2simplicial.latentclique_lifting module#

This module implements the LatentCliqueLifting class, which lifts graphs to simplicial complexes.

class topobench.transforms.liftings.graph2simplicial.latentclique_lifting.LatentCliqueLifting(edge_prob_mean: float = 0.9, edge_prob_var: float = 0.05, it=20, init='edges', do_gibbs=False, **kwargs)[source]#

Bases: Graph2SimplicialLifting

Lift graphs to cell complexes by identifying the cycles as 2-cells.

Parameters:
edge_prob_meanfloat = 0.9

Mean of the prior distribution of pie ~ Beta where edge_prob_mean must be in (0, 1). When edge_prob_mean is one, the value of edge_prob is fixed and not sampled.

edge_prob_varfloat = 0.05

Uncertainty of the prior distribution of pie ~ Beta(a, b) where edge_prob_var must be in [0, inf). When edge_prob_var is zero, the value of edge_prob is fixed and not sampled. It is require dthat edge_prob_var < edge_prob_mean * (1 - edge_prob_mean). When this is not the case the value of edge_prob_var is set to edge_prob_mean * (1 - edge_prob_mean) - 1e-6.

itint, optional

Number of iterations for sampling, by default None.

initstr, optional

Initialization method for the clique cover matrix, by default “edges”.

do_gibbsbool, optional

Whether to perform Gibbs sampling, by default False.

**kwargsoptional

Additional arguments for the class.

lift_topology(data: Data, verbose: bool = True) dict[source]#

Find the cycles of a graph and lifts them to 2-cells.

Parameters:
datatorch_geometric.data.Data

The input data to be lifted.

verbosebool, optional

Whether to display verbose output, by default False.

Returns:
dict

The lifted topology.

topobench.transforms.liftings.graph2simplicial.line_lifting module#

This module implements the SimplicialLineLifting class, which lifts graphs to simplicial complexes.

class topobench.transforms.liftings.graph2simplicial.line_lifting.SimplicialLineLifting(max_simplices=25, **kwargs)[source]#

Bases: Graph2SimplicialLifting

Lift graphs to a simplicial complex domain by considering line simplicial complex.

Line simplicial complex is a clique complex of the line graph. Line graph is a graph, in which the vertices are the edges in the initial graph, and two vertices are adjacent if the corresponding edges are adjacent in the initial graph.

Parameters:
max_simplicesint

Max simplices to add for each clique given a rank.

**kwargsoptional

Additional arguments for the class.

lift_topology(data: Data) dict[source]#

Lift topology of a graph to simplicial domain via line simplicial complex construction.

Parameters:
datatorch_geometric.data.Data

The input data to be lifted.

Returns:
dict

The lifted topology.

topobench.transforms.liftings.graph2simplicial.neighborhood_complex_lifting module#

This module implements the NeighborhoodComplexLifting class, which lifts graphs to simplicial complexes.

class topobench.transforms.liftings.graph2simplicial.neighborhood_complex_lifting.NeighborhoodComplexLifting(max_simplices=10, **kwargs)[source]#

Bases: Graph2SimplicialLifting

Lifts graphs to a simplicial complex domain by identifying the neighborhood complex as k-simplices.

Parameters:
max_simplicesint, optional

The maximum number of simplices to be added to the simplicial complex for each node. Default is 50.

**kwargsoptional

Additional arguments for the class.

lift_topology(data: Data) dict[source]#

Lift the topology of a graph to a simplicial complex.

Parameters:
datatorch_geometric.data.Data

The input data to be lifted.

Returns:
dict

The lifted topology.

topobench.transforms.liftings.graph2simplicial.vietoris_rips_lifting module#

This module implements the SimplicialVietorisRipsLifting class, which lifts graphs to simplicial complexes.

class topobench.transforms.liftings.graph2simplicial.vietoris_rips_lifting.SimplicialVietorisRipsLifting(distance_threshold=1.0, max_simplices=5, **kwargs)[source]#

Bases: Graph2SimplicialLifting

Lift graphs to simplicial complex domain using the Vietoris-Rips complex based on pairwise distances.

Parameters:
distance_thresholdfloat

The maximum distance between vertices to form a simplex.

max_simplicesint

Max number of simplices to create for a given node and rank.

**kwargsoptional

Additional arguments for the class.

lift_topology(data: Data) dict[source]#

Lift topology of a graph to a simplicial complex using the Vietoris-Rips complex.

Parameters:
datatorch_geometric.data.Data

The input data to be lifted.

Returns:
dict

The lifted topology.

Find nodes that all have distance less than distance_threshold.

Parameters:
nodeslist

Current list of nodes.

max_num_nodesint

Target number of nodes to return.

current_idxint

Index of the node from intersection to add. Can be None.

path_lengthsdict

Dictionary with path lengths between nodes in the graph.

intersectionlist

List of possible nodes to add.

distance_thresholdint

Max distance to consider for nodes.

Returns:
list

List of nodes where each pair of nodes had distance less or equal to the threshold. Returns None if there was no set of nodes satisfying the condition.

Module contents#

Graph2SimplicialLifting module with automated exports.

class topobench.transforms.liftings.graph2simplicial.Graph2SimplicialLifting(complex_dim=2, **kwargs)[source]#

Bases: GraphLifting

Abstract class for lifting graphs to simplicial complexes.

Parameters:
complex_dimint, optional

The maximum dimension of the simplicial complex to be generated. Default is 2.

**kwargsoptional

Additional arguments for the class.

class topobench.transforms.liftings.graph2simplicial.LatentCliqueLifting(edge_prob_mean: float = 0.9, edge_prob_var: float = 0.05, it=20, init='edges', do_gibbs=False, **kwargs)#

Bases: Graph2SimplicialLifting

Lift graphs to cell complexes by identifying the cycles as 2-cells.

Parameters:
edge_prob_meanfloat = 0.9

Mean of the prior distribution of pie ~ Beta where edge_prob_mean must be in (0, 1). When edge_prob_mean is one, the value of edge_prob is fixed and not sampled.

edge_prob_varfloat = 0.05

Uncertainty of the prior distribution of pie ~ Beta(a, b) where edge_prob_var must be in [0, inf). When edge_prob_var is zero, the value of edge_prob is fixed and not sampled. It is require dthat edge_prob_var < edge_prob_mean * (1 - edge_prob_mean). When this is not the case the value of edge_prob_var is set to edge_prob_mean * (1 - edge_prob_mean) - 1e-6.

itint, optional

Number of iterations for sampling, by default None.

initstr, optional

Initialization method for the clique cover matrix, by default “edges”.

do_gibbsbool, optional

Whether to perform Gibbs sampling, by default False.

**kwargsoptional

Additional arguments for the class.

lift_topology(data: Data, verbose: bool = True) dict#

Find the cycles of a graph and lifts them to 2-cells.

Parameters:
datatorch_geometric.data.Data

The input data to be lifted.

verbosebool, optional

Whether to display verbose output, by default False.

Returns:
dict

The lifted topology.

class topobench.transforms.liftings.graph2simplicial.NeighborhoodComplexLifting(max_simplices=10, **kwargs)#

Bases: Graph2SimplicialLifting

Lifts graphs to a simplicial complex domain by identifying the neighborhood complex as k-simplices.

Parameters:
max_simplicesint, optional

The maximum number of simplices to be added to the simplicial complex for each node. Default is 50.

**kwargsoptional

Additional arguments for the class.

lift_topology(data: Data) dict#

Lift the topology of a graph to a simplicial complex.

Parameters:
datatorch_geometric.data.Data

The input data to be lifted.

Returns:
dict

The lifted topology.

class topobench.transforms.liftings.graph2simplicial.SimplicialCliqueLifting(**kwargs)#

Bases: Graph2SimplicialLifting

Lift graphs to simplicial complex domain.

The algorithm creates simplices by identifying the cliques and considering them as simplices of the same dimension.

Parameters:
**kwargsoptional

Additional arguments for the class.

lift_topology(data: Data) dict#

Lift the topology of a graph to a simplicial complex.

Parameters:
datatorch_geometric.data.Data

The input data to be lifted.

Returns:
dict

The lifted topology.

class topobench.transforms.liftings.graph2simplicial.SimplicialDnDLifting(**kwargs)#

Bases: Graph2SimplicialLifting

Lift graphs to simplicial complex domain using a Dungeons & Dragons inspired system.

Parameters:
**kwargsoptional

Additional arguments for the class.

lift_topology(data: Data, max_simplices=10) dict#

Lift the topology of a graph to a simplicial complex using Dungeons & Dragons (D&D) inspired mechanics.

Parameters:
dataData

The input data to be lifted.

max_simplicesint

Maximum number of simplices to add for each node attribute.

Returns:
dict

The lifted topology.

class topobench.transforms.liftings.graph2simplicial.SimplicialEccentricityLifting(**kwargs)#

Bases: Graph2SimplicialLifting

Lift graphs to simplicial complex domain using eccentricity.

Parameters:
**kwargsoptional

Additional arguments for the class.

lift_topology(data: Data) dict#

Lift the topology of a graph to a simplicial complex by identifying connected subgraphs as simplices.

Parameters:
datatorch_geometric.data.Data

The input data to be lifted.

Returns:
dict

The lifted topology.

class topobench.transforms.liftings.graph2simplicial.SimplicialGraphInducedLifting(**kwargs)#

Bases: Graph2SimplicialLifting

Lift graphs to simplicial complex domain by identifying connected subgraphs as simplices.

Parameters:
**kwargsoptional

Additional arguments for the class.

lift_topology(data: Data) dict#

Lift the topology of a graph to a simplicial complex by identifying connected subgraphs as simplices.

Parameters:
datatorch_geometric.data.Data

The input data to be lifted.

Returns:
dict

The lifted topology.

class topobench.transforms.liftings.graph2simplicial.SimplicialKHopLifting(max_k_simplices=25, **kwargs)#

Bases: Graph2SimplicialLifting

Lift graphs to simplicial complex domain.

The function lifts a graph to a simplicial complex by considering k-hop neighborhoods. For each node its neighborhood is selected and then all the possible simplices, when considering the neighborhood as a clique, are added to the simplicial complex. For this reason this lifting does not conserve the initial graph topology.

Parameters:
max_k_simplicesint, optional

The maximum number of k-simplices to consider. Default is 25.

**kwargsoptional

Additional arguments for the class.

lift_topology(data: Data) dict#

Lift the topology to simplicial complex domain.

Parameters:
datatorch_geometric.data.Data

The input data to be lifted.

Returns:
dict

The lifted topology.

class topobench.transforms.liftings.graph2simplicial.SimplicialLineLifting(max_simplices=25, **kwargs)#

Bases: Graph2SimplicialLifting

Lift graphs to a simplicial complex domain by considering line simplicial complex.

Line simplicial complex is a clique complex of the line graph. Line graph is a graph, in which the vertices are the edges in the initial graph, and two vertices are adjacent if the corresponding edges are adjacent in the initial graph.

Parameters:
max_simplicesint

Max simplices to add for each clique given a rank.

**kwargsoptional

Additional arguments for the class.

lift_topology(data: Data) dict#

Lift topology of a graph to simplicial domain via line simplicial complex construction.

Parameters:
datatorch_geometric.data.Data

The input data to be lifted.

Returns:
dict

The lifted topology.

class topobench.transforms.liftings.graph2simplicial.SimplicialVietorisRipsLifting(distance_threshold=1.0, max_simplices=5, **kwargs)#

Bases: Graph2SimplicialLifting

Lift graphs to simplicial complex domain using the Vietoris-Rips complex based on pairwise distances.

Parameters:
distance_thresholdfloat

The maximum distance between vertices to form a simplex.

max_simplicesint

Max number of simplices to create for a given node and rank.

**kwargsoptional

Additional arguments for the class.

lift_topology(data: Data) dict#

Lift topology of a graph to a simplicial complex using the Vietoris-Rips complex.

Parameters:
datatorch_geometric.data.Data

The input data to be lifted.

Returns:
dict

The lifted topology.