@@ -69,7 +69,7 @@ def weighted_simplex(simplex: tuple) -> dict:
6969 simplex = tuple of vertex labels
7070
7171 Returns:
72- dictionary mapping simplices to strictly positive topological.
72+ dictionary mapping simplices to strictly positive topological weights .
7373
7474 """
7575 weights = defaultdict (float )
@@ -98,7 +98,7 @@ def unit_simplex(sigma: tuple, c: float = 1.0, closure: bool = False) -> dict:
9898## From: https://stackoverflow.com/questions/42138681/faster-numpy-solution-instead-of-itertools-combinations
9999@cache
100100def _combs (n : int , k : int ) -> np .ndarray :
101- """Faster numpy-version of itertools.combinations over the standard indest set {0, 1, ..., n}"""
101+ """Faster numpy-version of itertools.combinations over the standard index set {0, 1, ..., n}"""
102102 if n < k :
103103 return np .empty (shape = (0 ,), dtype = int )
104104 a = np .ones ((k , n - k + 1 ), dtype = int )
@@ -114,12 +114,12 @@ def _combs(n: int, k: int) -> np.ndarray:
114114
115115
116116def downward_closure (H : list , d : int = 1 , coeffs : bool = False ):
117- """Constructs a simplicial complex from a hypergraph by taking its downward closure , optionally counting higher order interactions.
117+ """Constructs the d-simplices of the downward closure of a hypergraph , optionally counting higher order interactions.
118118
119119 This function implicitly converts a hypergraph into a simplicial complex by taking the downward closure of each hyperedge
120120 and collecting the corresponding d-simplices. Note that only the d-simplices are returned (maximal p-simplices for p < d
121- won't be included!). If coeffs = True, a n x D sparse matrix is returned whose non-zero values at index (i,j) count the number of
122- times the corresponding i-th d-simplex appeared in a j-dimensional hyperedge.
121+ won't be included!). If coeffs = True, a n x D sparse matrix is returned whose (i,j) non-zero values count the number of
122+ times the i-th d-simplex appeared in a j-dimensional hyperedge.
123123
124124 The output of this function is meant to be used in conjunction with top_weights to compute topological weights.
125125
@@ -145,6 +145,7 @@ def downward_closure(H: list, d: int = 1, coeffs: bool = False):
145145 return S
146146
147147 ## Extract the lengths of the hyperedges and how many d-simplices we may need
148+ ## NOTE: The use of hirola here speeds up the computation tremendously
148149 from hirola import HashTable
149150
150151 H_sizes = np .array ([len (he ) for he in H ])
@@ -203,7 +204,7 @@ def top_weights(simplices: np.ndarray, coeffs: sparray, normalize: bool = False)
203204
204205
205206def vertex_counts (H : list ) -> np .ndarray :
206- """Returns the number of times a """
207+ """Counts the vertex cardinalities of a set of hyperedges. """
207208 N = np .max ([np .max (he ) for he in normalize_hg (H )]) + 1
208209 v_counts = np .zeros (N )
209210 for he in normalize_hg (H ):
@@ -236,7 +237,6 @@ def lift_topology(self, data: torch_geometric.data) -> dict:
236237 dict
237238 The lifted topology.
238239 """
239- print ("Lifting to weighted simplicial complex" )
240240
241241 ## Convert incidence to simple list of hyperedges
242242 R , C = data .incidence_hyperedges .coalesce ().indices ().detach ().numpy ()
0 commit comments