topobench.transforms.liftings.graph2cell package#
Submodules#
topobench.transforms.liftings.graph2cell.base module#
Abstract class for lifting graphs to cell complexes.
- class topobench.transforms.liftings.graph2cell.base.Graph2CellLifting(complex_dim=2, **kwargs)[source]#
Bases:
GraphLifting
Abstract class for lifting graphs to cell complexes.
- Parameters:
- complex_dimint, optional
The dimension of the cell complex to be generated. Default is 2.
- **kwargsoptional
Additional arguments for the class.
topobench.transforms.liftings.graph2cell.cycle_lifting module#
This module implements the cycle lifting for graphs to cell complexes.
- class topobench.transforms.liftings.graph2cell.cycle_lifting.CellCycleLifting(max_cell_length=None, **kwargs)[source]#
Bases:
Graph2CellLifting
Lift graphs to cell complexes.
The algorithm creates 2-cells by identifying the cycles and considering them as 2-cells.
- Parameters:
- max_cell_lengthint, optional
The maximum length of the cycles to be lifted. Default is None.
- **kwargsoptional
Additional arguments for the class.
topobench.transforms.liftings.graph2cell.discrete_configuration_complex_lifting module#
This module implements the discrete configuratio complex lifting lifting for graphs to cell complexes.
- class topobench.transforms.liftings.graph2cell.discrete_configuration_complex_lifting.DiscreteConfigurationComplexLifting(k: int, preserve_edge_attr: bool = True, feature_aggregation='concat', **kwargs)[source]#
Bases:
Graph2CellLifting
Lift graphs to cell complexes.
Lift graphs to cell complexes by generating the k-th discrete configuration complex D_k(G) of the graph. This is a cube complex, which is similar to a simplicial complex except each n-dimensional cell is homeomorphic to a n-dimensional cube rather than an n-dimensional simplex.
The discrete configuration complex of order k consists of all sets of k unique edges or vertices of G, with the additional constraint that if an edge e is in a cell, then neither of the endpoints of e are in the cell. For examples of different graphs and their configuration complexes, see the tutorial.
Note that since TopoNetx only supports cell complexes of dimension 2, if you generate a configuration complex of order k > 2 this will only produce the 2-skeleton.
- Parameters:
- kint
The order of the configuration complex, i.e. the number of ‘agents’ in a single configuration.
- preserve_edge_attrbool, optional
Whether to preserve edge attributes. Default is True.
- feature_aggregationstr, optional
For a k-agent configuration, the method by which the features are aggregated. Can be “mean”, “sum”, or “concat”. Default is “concat”.
- **kwargsdict, optional
Additional arguments for the class.
Notes
The discrete configuration complex provides a way to model higher-order interactions in graphs, particularly useful for scenarios involving multiple agents or particles moving on a graph structure.
- topobench.transforms.liftings.graph2cell.discrete_configuration_complex_lifting.edge_cycle_to_vertex_cycle(edge_cycle: list[list | tuple])[source]#
Take a cycle represented by a list of edges and returns a vertex representation: [(1, 2), (0, 1), (1, 2)] -> [1, 2, 3].
- Parameters:
- edge_cyclelist[list | tuple]
The cycle represented by a list of edges.
- Returns:
- list
The cycle represented by a list of vertices.
- topobench.transforms.liftings.graph2cell.discrete_configuration_complex_lifting.generate_configuration_class(graph: Graph, feature_aggregation: str, edge_features: bool)[source]#
Factory for the Configuration class.
- Parameters:
- graphnx.Graph
The input graph.
- feature_aggregationstr
The method by which the features are aggregated.
- edge_featuresbool
Whether edge features are present.
- Returns:
- Configuration
The Configuration.
Module contents#
Graph2Cell liftings with automated exports.
- class topobench.transforms.liftings.graph2cell.CellCycleLifting(max_cell_length=None, **kwargs)#
Bases:
Graph2CellLifting
Lift graphs to cell complexes.
The algorithm creates 2-cells by identifying the cycles and considering them as 2-cells.
- Parameters:
- max_cell_lengthint, optional
The maximum length of the cycles to be lifted. Default is None.
- **kwargsoptional
Additional arguments for the class.
- class topobench.transforms.liftings.graph2cell.DiscreteConfigurationComplexLifting(k: int, preserve_edge_attr: bool = True, feature_aggregation='concat', **kwargs)#
Bases:
Graph2CellLifting
Lift graphs to cell complexes.
Lift graphs to cell complexes by generating the k-th discrete configuration complex D_k(G) of the graph. This is a cube complex, which is similar to a simplicial complex except each n-dimensional cell is homeomorphic to a n-dimensional cube rather than an n-dimensional simplex.
The discrete configuration complex of order k consists of all sets of k unique edges or vertices of G, with the additional constraint that if an edge e is in a cell, then neither of the endpoints of e are in the cell. For examples of different graphs and their configuration complexes, see the tutorial.
Note that since TopoNetx only supports cell complexes of dimension 2, if you generate a configuration complex of order k > 2 this will only produce the 2-skeleton.
- Parameters:
- kint
The order of the configuration complex, i.e. the number of ‘agents’ in a single configuration.
- preserve_edge_attrbool, optional
Whether to preserve edge attributes. Default is True.
- feature_aggregationstr, optional
For a k-agent configuration, the method by which the features are aggregated. Can be “mean”, “sum”, or “concat”. Default is “concat”.
- **kwargsdict, optional
Additional arguments for the class.
Notes
The discrete configuration complex provides a way to model higher-order interactions in graphs, particularly useful for scenarios involving multiple agents or particles moving on a graph structure.
- forward(data: Data) Data #
Apply the full lifting (topology + features) to the input data.
- Parameters:
- datatorch_geometric.data.Data
The input data to be lifted.
- Returns:
- torch_geometric.data.Data
The lifted data.
- class topobench.transforms.liftings.graph2cell.Graph2CellLifting(complex_dim=2, **kwargs)[source]#
Bases:
GraphLifting
Abstract class for lifting graphs to cell complexes.
- Parameters:
- complex_dimint, optional
The dimension of the cell complex to be generated. Default is 2.
- **kwargsoptional
Additional arguments for the class.