topobench.transforms.liftings.liftings module#
This module implements the abstract classes for lifting graphs.
- class AbstractLifting(feature_lifting=None, **kwargs)#
Bases:
BaseTransformAbstract class for topological liftings.
- Parameters:
- feature_liftingstr, optional
The feature lifting method to be used. Default is ‘ProjectionSum’.
- **kwargsoptional
Additional arguments for the class.
- __init__(feature_lifting=None, **kwargs)#
- forward(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.
- abstract lift_topology(data)#
Lift the topology of a graph to higher-order topological domains.
- Parameters:
- datatorch_geometric.data.Data
The input data to be lifted.
- Returns:
- dict
The lifted topology.
- class CellComplexLifting(feature_lifting='ProjectionSum', **kwargs)#
Bases:
AbstractLiftingAbstract class for lifting cell complexes to other domains.
- Parameters:
- feature_liftingstr, optional
The feature lifting method to be used. Default is ‘ProjectionSum’.
- **kwargsoptional
Additional arguments for the class.
- __init__(feature_lifting='ProjectionSum', **kwargs)#
- class CombinatorialLifting(feature_lifting='ProjectionSum', **kwargs)#
Bases:
AbstractLiftingAbstract class for lifting combinatorial complexes to other domains.
- Parameters:
- feature_liftingstr, optional
The feature lifting method to be used. Default is ‘ProjectionSum’.
- **kwargsoptional
Additional arguments for the class.
- __init__(feature_lifting='ProjectionSum', **kwargs)#
- class GraphLifting(feature_lifting='ProjectionSum', preserve_edge_attr=False, **kwargs)#
Bases:
AbstractLiftingAbstract class for lifting graph topologies to other domains.
- Parameters:
- feature_liftingstr, optional
The feature lifting method to be used. Default is ‘ProjectionSum’.
- preserve_edge_attrbool, optional
Whether to preserve edge attributes. Default is False.
- **kwargsoptional
Additional arguments for the class.
- __init__(feature_lifting='ProjectionSum', preserve_edge_attr=False, **kwargs)#
- class HypergraphLifting(feature_lifting='ProjectionSum', **kwargs)#
Bases:
AbstractLiftingAbstract class for lifting hypergraphs to other domains.
- Parameters:
- feature_liftingstr, optional
The feature lifting method to be used. Default is ‘ProjectionSum’.
- **kwargsoptional
Additional arguments for the class.
- __init__(feature_lifting='ProjectionSum', **kwargs)#
- class PointCloudLifting(feature_lifting='ProjectionSum', **kwargs)#
Bases:
AbstractLiftingAbstract class for lifting point clouds to other topological domains.
- Parameters:
- feature_liftingstr, optional
The feature lifting method to be used. Default is ‘ProjectionSum’.
- **kwargsoptional
Additional arguments for the class.
- __init__(feature_lifting='ProjectionSum', **kwargs)#
- class SimplicialLifting(feature_lifting='ProjectionSum', **kwargs)#
Bases:
AbstractLiftingAbstract class for lifting simplicial complexes to other domains.
- Parameters:
- feature_liftingstr, optional
The feature lifting method to be used. Default is ‘ProjectionSum’.
- **kwargsoptional
Additional arguments for the class.
- __init__(feature_lifting='ProjectionSum', **kwargs)#
- is_undirected(edge_index, edge_attr=None, num_nodes=None)#
Returns
Trueif the graph given byedge_indexis undirected.- Parameters:
edge_index (LongTensor) – The edge indices.
edge_attr (Tensor or List[Tensor], optional) – Edge weights or multi- dimensional edge features. If given as a list, will check for equivalence in all its entries. (default:
None)num_nodes (int, optional) – The number of nodes, i.e.
max(edge_index) + 1. (default:None)
- Return type:
Examples
>>> edge_index = torch.tensor([[0, 1, 0], ... [1, 0, 0]]) >>> weight = torch.tensor([0, 0, 1]) >>> is_undirected(edge_index, weight) True
>>> weight = torch.tensor([0, 1, 1]) >>> is_undirected(edge_index, weight) False
- to_undirected(edge_index, edge_attr='???', num_nodes=None, reduce='add')#
Converts the graph given by
edge_indexto an undirected graph such that \((j,i) \in \mathcal{E}\) for every edge \((i,j) \in \mathcal{E}\).- Parameters:
edge_index (LongTensor) – The edge indices.
edge_attr (Tensor or List[Tensor], optional) – Edge weights or multi- dimensional edge features. If given as a list, will remove duplicates for all its entries. (default:
None)num_nodes (int, optional) – The number of nodes, i.e.
max(edge_index) + 1. (default:None)reduce (str, optional) – The reduce operation to use for merging edge features (
"add","mean","min","max","mul"). (default:"add")
- Return type:
LongTensorifedge_attris not passed, else (LongTensor,Optional[Tensor]orList[Tensor]])
Warning
From :pyg:`PyG >= 2.3.0` onwards, this function will always return a tuple whenever
edge_attris passed as an argument (even in case it is set toNone).Examples
>>> edge_index = torch.tensor([[0, 1, 1], ... [1, 0, 2]]) >>> to_undirected(edge_index) tensor([[0, 1, 1, 2], [1, 0, 2, 1]])
>>> edge_index = torch.tensor([[0, 1, 1], ... [1, 0, 2]]) >>> edge_weight = torch.tensor([1., 1., 1.]) >>> to_undirected(edge_index, edge_weight) (tensor([[0, 1, 1, 2], [1, 0, 2, 1]]), tensor([2., 2., 1., 1.]))
>>> # Use 'mean' operation to merge edge features >>> to_undirected(edge_index, edge_weight, reduce='mean') (tensor([[0, 1, 1, 2], [1, 0, 2, 1]]), tensor([1., 1., 1., 1.]))