4.6 From a discrete gradient to the Morse complex:
4.6.2 Description in the simplicial case
In this section, we focus on the case of X being a simplicial complex to describe the algorithm BoundaryMaps as done in [93]. The algorithm is implemented for the experimental results in Chapter6. For the input and the output of the algorithm, we take the notation of the previous section. The pseudocode of BoundaryMaps is reported in Algorithm 5. First, we make the representation of entities in the simplicial case explicit. Then, we describe the auxiliary functions called by BoundaryMaps. Afterwards, we describe the procedure of the algorithm. Finally, we provide some computational remarks on the simplicial case.
For representing the simplicial complex X , we assume a representation such that the top-simplices incident to a given vertex can be retrieved in linear time with respect to the number of top-simplices incident to the vertex. Moreover, we assume to have constant access to the vertexes of a cell. This property is met by representations such as the adjacency-based IA* data structure [30] and the incidence-based implementation for triangle meshes described in Section6.1.2.
For representing the discrete gradient, our description assumes the representation introduced in [86] for triangular meshes and in [193] for tethrahedral meshes. The discrete gradient V is represented by a bit-array as an attribute for each top-simplex t in X . In the bit-array, each entry defines a possible discrete vector between faces of t. Discrete vectors are given by valued-1 entries in the array.
Algorithm 5 BoundaryMaps(X ,V ,t)
Input: X , d-dimensional regular cell complex Input: V , discrete gradient on X
Input: t, critical cell
Output: Bptq, boundary maps as collections of arcs
1: Q Ð H
2: Q.enqueueptq # Q is an empty queue
3: while Q ‰ H do 4: t0Ð Q.dequeuepq
5: for s1PgetFacetspt0, X q do # s1is a facet of t1in X 6: if isPairedps1,V q then # s1is not critical 7: t1ÐgetPairComponentps1,V q # ps1,t1q P V 8: Q.enqueuept1q
9: else # s1is critical
10: addpBptq,t0, s1q # the value identifying s1is appended to Bptq 11: end if
12: end for
13: end while
14: return Bptq
• getFacetspt, Xq returns a list of facets of the simplex t in X. This is done in linear time in the dimension of the simplex t, since each facets is obtained by removing a vertex from those defining t;
• isPairedps,V q returns the value True if s belongs to a discrete vector ps,tq in V , and the value False otherwise. In the former case it also returns the paired cell. This is done by examining all the top simplices in the star of a vertex w of s. For each top-simplex its bit-vector is visited limitedly to the entries defining suitable pairs ps,tq. The operation requires Op|tw|q, where twdenotes the set of top simplices incident in a vertex w of a.
• getPairComponentps,V q is used to return, in the pseudocode, the cofacet t of s returned by isPairps,V q.
Starting from a critical cell t of dimension k, a breadth-first traversal is performed by navigating from t to its adjacent k-cells passing through their shared pk ´ 1q-cells (by intersection property, adjacent k-cells share one, and only one, facet). The breadth-first traversal is supported by a queue Q. Given a k-cell t0extracted from the queue Q (row 8), we examine all of its facets in X , returned
by the auxiliary function getFacets (row 11). For each pk ´ 1q-cell s1, if s1is part of a discrete
vector together with a k-cell t1returned by function isPair (row 12), t1is added to the queue (rows
while-loop terminates, the list Bptq is returned.
Algorithm 5is executed for a critical k-simplex t in the Morse set MpV q relative to a discrete gradient V . A cell t0is popped out from Q up to k times, with k the number of facets of t0. For
each facet s1of t0we check whether it is paired or not which takes, by assumption at most time
Op|tw|q. Then, we can conclude that each iteration of the while loop takes Opk ¨ |t|q, where t is the
maximal-sized set of top-simplices incident in w. Hence, the algorithm has Opq ¨ k ¨ |t|q worst-case time complexity, where q is the number (counted with multiplicity) of k-simplices of X inserted in the queue Q. In practical cases, time complexity is dominated by the factor q. Concerning the retrieval of the boundary map for all critical cells, we can build degenerate cases where each critical cell is connected, through a V -path, to all the cells of the same dimension in X . This raises the complexity to be cubic in the number of cells. In practice, each cell belongs to the descending path of a limited number of critical cells (possibly zero). In Section6.4.3, we see the measured timings for BoundaryMaps applied to some entire Morse sets of large size.