scott.topology.ph¶
- class scott.topology.ph.GraphHomology(homology_dims: List[int] | None = None, filter_attribute: str = 'curvature', mask_infinite_features: bool = False, extended_persistence: bool = True)[source]¶
Bases:
object
Compute persistent homology on graphs by filtering over edge attributes.
This class uses Gudhi’s
SimplexTree
to build a clique complex on a given graph and compute persistence diagrams for homology groups, using an edge attribute (e.g. curvature) as a filtration function.- homology_dims¶
Dimensions of the homology groups to compute (e.g., [0, 1] for H_0 and H_1). Default is [0, 1].
- Type:
List[int]
- filter_attribute¶
The edge attribute to use as the filtration value. Default is “curvature”.
- Type:
str, optional
- __init__(homology_dims: List[int] | None = None, filter_attribute: str = 'curvature', mask_infinite_features: bool = False, extended_persistence: bool = True)[source]¶
Initializes the GraphHomology class with parameters for homology computation.
- Parameters:
homology_dims (list of int, optional) – Dimensions of the homology groups to compute (e.g., [0, 1] for H_0 and H_1). Default is [0, 1].
filter_attribute (str, optional) – The edge attribute to use as the filtration value. Default is “curvature”.
- calculate_persistent_homology(G: Graph) PersistenceDiagram [source]¶
Calculates persistent homology of the graph’s clique complex.
- Parameters:
G (networkx.Graph) – Input graph with edges that contain attributes for filtration.
- Returns:
A persistence diagram wrapper for the topological information from a curvature filtration. Attribute persistence_pts stores a Dict[int, np.array] that a maps homology dimension key to a np.array of its persistence pairs.
- Return type:
- Raises:
ValueError – If the specified
filter_attribute
is not found in an edge’s attributes.