# Empowering Advanced Parametric Modes Clustering from Topological Data Analysis
## 2 Methods
### On the Surface Topology
#### 2.2.5 Matching Persistence Diagrams  
Consider two data-sets \(\mathbb{M}_{r}\) and \(\mathbb{M}_{s}\) representing two deformed configurations of the same surface. A matching between two persistence diagrams with the same number of features, \(\mathcal{PD}_{k}(\mathbb{M}_{r})\) and \(\mathcal{PD}_{k}(\mathbb{M}_{s})\), for \(k=0,1,2\), is a bijective map \(\psi^{k}\) that reads:  
\[\psi^{k}:\mathcal{PD}_{k}(\mathbb{M}_{r})\longrightarrow\ \mathcal{PD}_{k}( \mathbb{M}_{s}),\]  
such that \(\forall\gamma=(b,d)\in\mathcal{PD}_{k}(\mathbb{M}_{r})\),  
\[\psi^{k}(\gamma) =(\psi^{k}_{1}(b),\psi^{k}_{2}(d))\] \[=(b^{\prime},d^{\prime})\in\mathcal{PD}_{k}(\mathbb{M}_{s}).\]  
The map \(\psi^{k}\) associates each feature from \(\mathcal{PD}_{k}(\mathbb{M}_{r})\) to a feature from \(\mathcal{PD}_{k}(\mathbb{M}_{s})\). The _Optimal Matching_ between \(\mathcal{PD}_{k}(\mathbb{M}_{r})\) and \(\mathcal{PD}_{k}(\mathbb{M}_{s})\) is a matching \(\hat{\psi}^{k}\)  
\[\hat{\psi}^{k}:\mathcal{PD}_{k}(\mathbb{M}_{r})\longrightarrow\ \mathcal{PD}_{k}( \mathbb{M}_{s}),\]  
\begin{table}
\begin{tabular}{c c c c c} \hline \(\alpha\) & \(S^{\alpha}_{0}\) & \(S^{\alpha}_{1}\) & \(S^{\alpha}_{2}\) & \(S^{\alpha}_{3}\) \\ \hline
70.64 & \([x_{0}],[x_{1}],[x_{2}]\) & \([x_{1},x_{3}],[x_{0},x_{4}]\) & \([x_{1},x_{2},x_{5}],[x_{1},x_{3},x_{5}]\) & - \\  & \([x_{3}],[x_{4}],[x_{5}]\) & \([x_{0},x_{2}],[x_{4},x_{5}]\) & \([x_{0},x_{1},x_{2}],[x_{3},x_{4},x_{5}]\) & \\  & & \([x_{1},x_{2}],[x_{3},x_{5}]\) & & \\  & & \([x_{2},x_{5}],[x_{2},x_{4}]\) & & \\  & & \([x_{1},x_{5}],[x_{0},x_{1}]\) & & \\  & & \([x_{3},x_{4}]\) & & \\ \hline
71.38 & \([x_{0}],[x_{1}],[x_{2}]\) & \([x_{1},x_{3}],[x_{0},x_{4}]\) & \([x_{1},x_{2},x_{5}],[x_{1},x_{3},x_{5}]\) & - \\  & \([x_{3}],[x_{4}],[x_{5}]\) & \([x_{0},x_{2}],[x_{4},x_{5}]\) & \([x_{0},x_{1},x_{2}],[x_{3},x_{4},x_{5}]\) & \\  & & \([x_{1},x_{2}],[x_{3},x_{5}]\) & \([x_{0},x_{1},x_{4}],[x_{1},x_{3},x_{4}]\) & \\  & & \([x_{2},x_{5}],[x_{2},x_{4}]\) & & \\  & & \([x_{1},x_{5}],[x_{0},x_{1}]\) & & \\  & & \([x_{3},x_{4}],[x_{1},x_{4}]\) & & \\ \hline
71.55 & \([x_{0}],[x_{1}],[x_{2}]\) & \([x_{1},x_{3}],[x_{0},x_{4}]\) & \minimizing the transport cost \(\mathcal{C}^{k}\) to move the features from \(\mathcal{PD}_{k}(\mathbb{M}_{r})\) to \(\mathcal{PD}_{k}(\mathbb{M}_{s})\):  
\[\mathcal{C}^{k}_{\mathtt{min}} =\sum_{\gamma\in\mathcal{PD}_{k}(\mathbb{M}_{r})}\left\|\gamma- \hat{\psi}^{k}(\gamma)\right\|_{2}\] \[=\sum_{(b,d)\in\mathcal{PD}_{k}(\mathbb{M}_{r})}\left\|\left(b- \hat{\psi}^{k}_{1}(b),d-\hat{\psi}^{k}_{2}(d)\right)\right\|_{2}\] \[=\sum_{(b,d)\in\mathcal{PD}_{k}(\mathbb{M}_{r})}\sqrt{\left(b- \hat{\psi}^{k}_{1}(b)\right)^{2}+\left(d-\hat{\psi}^{k}_{2}(d)\right)^{2}}.\]  
When \(\mathbb{M}_{r}\) is the reference surface, and \(\mathbb{M}_{s}\) is any deformed surface resulting from \(\mathbb{M}_{r}\), the optimal matching \(\hat{\psi}^{k}\) represents and quantifies the deformation from a topological viewpoint, at each dimension \(k=0,1,2\).  
We note that, in our case considered here, the diagrams have all been reduced to their top 3000 persistence values, making the bijective matching possible. In the case of diagrams with a different number of points, a partial matching is rather considered.  
The optimal matching is computed using a combinatorial optimization procedure, where the points in both diagrams are matched while minimizing the transport cost function defined above. A graphical representation of the matching is shown in Figure 5.