SlowGuess/NeurIPS_2023_OCR huggingface dataset:
Algorithm 1 IS HIGHLY CONNECTED: tests if two clusters are highly connected.
function ISHIGHLYCONNECTED  
Input: vertex set  $X, Y$  and edge set  $E$   
For  $x \in X$ :  
    If  $|\{y \in Y | (x, y) \in E\}| < \frac{|Y|}{2}$ :  
    return False  
For  $y \in Y$ :  
    If  $|\{x \in X | (x, y) \in E\}| < \frac{|X|}{2}$ :  
    return False  
return True
Figure 1: Illustration of highly connectedness condition
Algorithm 2 HCCTRIANGLE: Find HCC which respects triangle objectives
function HCCTRIANGLE Input:  $V = \{v_{1},\dots ,v_{n}\}$  and an ordering of all pairs  $\{e_1,e_2,\dots ,e_{\binom{n}{2}}\}$  on  $V$  so that  $E_{t} = \{e_{1},e_{2},\dots ,e_{t}\}$  Desired Output: hierarchical partition  $\{P_t\}$  for  $0\leq t\leq \binom {n}{2} = k$  so that  $|E_{t}\Delta E(P_{t})|\leq 4\cdot |B(G_{t})|$  holds for every  $t$  Init:  $\mathcal{P} = \{\{v_1\} ,\{v_2\} ,\dots ,\{v_n\} \}$ $P_0\gets \mathcal{P}$  For  $t\in \{1,2,\dots ,(^n\big)_2\}$  : Take  $e_t = (x,y)$  with  $x\in C_x$  and  $y\in C_y$ $(C_x,C_y\in \mathcal{P})$  If  $C_x\neq C_y$  If ISHIGLYCONNECTED  $(C_x,C_y,E_t)$  is true: add  $C = C_x\cup C_y$  and remove  $C_x,C_y$  in  $\mathcal{P}$  -  $P_{t}\gets \mathcal{P}$  return  $\{P_t\}$
In the rest of this subsection, we provide a sketch of the proof that HCCTRIANGLE provides the desired correlation clustering (the detailed proof can be found in Appendix 6.4). We denote the output of HCCTRIANGLE by  $\{P_t\}$  and also assume  $E = E_t$  and  $P_t = \{C_1, C_2, \dots, C_k\}$ . The algorithm HCCTRIANGLE agglomerates two clusters if they are highly connected, adds the cluster to the partition, and iterates. The key to the ordering of the edges input to HCCTRIANGLE is that they are ordered by increasing distance so that the number of edges that are in "disagreement" in
Algorithm 3 HCCULTRAFIT: Ultrametric fitting algorithm, uses HCCTRIANGLE
function HCCULTRAFit(d) Sort  $\binom{X}{2}$  as  $\{e_1,\dots ,e_{\binom{n}{2}}\}$  so that  $d(e_1)\leq d(e_2)\leq \dots \leq d(e_{\binom{n}{2}})$ $\{P_t\} =$  HCCTRIANGLE(X,{et})  $d_U(x,y)\gets d(e_j)$  where  $j = \mathrm{argmin}_t(x,y$  are in same cluster in  $P_{t}$  return  $d_{U}$
the correlation clustering is upper bounded by the number of edges whose distances "violate" a triangle relationship. The proof proceeds in a bottom up fashion. (It is clear that the output partition is naturally hierarchical.) We count the number of bad triangles "within" and "between" clusters, which are lower bounded by the number of disagreement edges "within" and "between" clusters, respectively. The proof uses several combinatorial properties which follow from the highly connected condition. This is the key point of our proof.
From an ultrametricity fit to a rooted tree fit: Following a procedure from Cohen-Addad, et al. [1], we can also obtain a tree fit with the  $\ell_1 / \ell_1$  objective. Note that the algorithm HCCROOTEDTREEFIT takes the generic reduction method from ultrametric fitting algorithm but we have instantiated it with HCCULTRAfit. For a self-contained proof, see the Appendix 6.3.
Proof of Theorem 3.5: This proof can be easily shown simply by applying Theorem 2.5 with  $p = q = 1$  and  $f(n) = 4\binom{n}{3}$ .
Algorithm 4 Find a tree fitting given an ultrametric fitting procedure
1: procedure HCCROOTEDTREEFIT  
2: Input: distance function  $d$  on  $\binom{X}{2}$  and base point  $w \in X$   
3: Output: (rooted) tree metric  $d_{T}$  which fits  $d$  and  $d(x, w) = d_{T}(x, w)$  for all  $x \in X$   
4:  $M \gets \max_{x \in X} d(x, w)$   
5:  $c_{w}(x, y) \gets 2M - d(x, w) - d(y, w)$  for all  $x, y \in \binom{X}{2}$   
6:  $d_{U} \gets \text{HCCULTRAFIT}(d + c_{w})$   
7:  $d_{T} \gets d_{U} - c_{w}$   
8: return  $d_{T}$
Running Time Although ISHIGHLYCONNECTED is seemingly expensive, there is a way to implement HCCTRIANGLE so that all procedures run in  $O(n^{2})$  time. Thus, HCCULTRAFIT can be implemented so as to run in  $O(n^{2}\log n)$  time. The detailed algorithm can be found in Appendix 6.5.
Asymptotic Tightness Consider  $(d,X)$  with  $X = \{x_{1},\dots ,x_{n}\}$  and  $d(x_{1},x_{2}) = d(x_{1},x_{3}) = 1$  and 2 otherwise. Then we see that  $tp(d;x_1,x_2,x_3) = 1$  and 0 otherwise, so that  $\| \Delta \| _p = 1$ . One can easily check that for any ultrametric  $d_U$ ,  $|\epsilon (x_1,x_2)|^p +|\epsilon (x_1,x_3)|^p +|\epsilon (x_2,x_3)|^p\geq 2^{1 - p}$  for  $\epsilon \coloneqq d_U - d$ . When  $p = 1$ ,  $\| d - d_U\| _1\geq \| \Delta (d)\| _1 = \binom{n}{3}\operatorname {AvgUM}(d)$  holds for any ultrametric  $d_U$ . While HCCULTRAfit guarantees  $\| d - d_U\| _1\leq 4\| \Delta (d)\| _1 = 4\binom{n}{3}\operatorname {AvgUM}(d)$ ; this shows that our theoretical bound is asymptotically tight.
Examples demonstrating how HCCULTRAfit works and related discussion can be found in Appendix 6.7.1.
In this section, we run HCCROOTEDTREEFIT on several different type of data sets, those that are standard for geometric graph neural nets and those that are synthetic. We also compare our results with other known algorithms. We conclude that HCCROOTEDTREEFIT (HCC) is optimal when the data sets are close to tree-like and when we measure with respect to distortion in the  $\ell_1$  sense and running time. It is, however, suboptimal in terms of the  $\ell_{\infty}$  measure of distortion (as to be expected). We also conclude that purportedly hierarchical data sets do not, in fact, embed into trees with low distortion, suggesting that geometric graph neural nets should be configured with different geometric considerations. Appendix 6.9 contains further details regarding the experiments.
Data set	C-ELEGAN	CS PHD	CORA	AIRPORT
n	452	1025	2485	3158
\( \text{Hyp}(d) \)	1.5	6.5	11	1
\( \text{AvgHyp}(d) \)	0.13	0.51	0.36	0.18
Bound	158.0	1384.5	2376.2	1547.1
HCC	0.90±0.19	2.60±1.11	2.42±0.44	1.09±0.15
Gromov	1.14±0.04	2.79±0.36	3.38±0.13	1.56±0.08
TR	0.83±0.16	2.55±1.34	2.91±0.63	1.28±0.21
NJ	0.30	1.35	1.06	0.49
Table 2: Connection between hyperbolicity and average hyperbolicity and how these quantities determine the average distortion  $(\| d - d_T\| _1 / \binom{n}{2})$  of the resulting tree metric.
Data set	C-ELEGAN	CS PHD	CORA	AIRPORT
HCC	4.3±0.64	23.37±3.20	19.30±1.11	7.63±0.54
Gromov	3.32±0.47	13.24±0.67	9.23±0.53	4.04±0.20
TR	5.90±0.72	21.01±3.34	16.86±2.11	10.00±1.02
NJ	2.97	16.81	13.42	4.18
4.1 Common data sets
We used common unweighted graph data sets which are known to be hyperbolic or close to tree-like and often used in graph neural nets, especially those with geometric considerations. The data sets we used are C-ELEGAN, CS PhD from [14], and CORA, AIRPORT from [15]. (For those which contain multiple components, we chose the largest connected component.) Given an unweighted graph, we computed its shortest-path distance matrix and used that input to obtain a tree metric. We compared these results with the following other tree fitting algorithms TREEREP (TR) [9], NEIGHBORJOIN (NJ) [8], and the classical Gromov algorithm. As TREEREP is a randomized algorithm and HCCROOTEDTREEFIT and Gromov's algorithm depends on the choice of a pivot vertex, we run all of these algorithms 100 times and report the average error with standard deviation. All edges with negative weights have been modified with weight 0, as TREEREP and NEIGHBORJOIN both occasionally produce edges with negative weights. Recall, both TREEREP and NEIGHBORJOIN enjoy no theoretical guarantees on distortion.
First, we examine the results in Table 2. We note that although the guaranteed bound (of average distortion),  $8\binom{n-1}{3}\operatorname{AvgHyp}(d)/\binom{n}{2}$  is asymptotically tight even in worst case analysis, this bound is quite loose in practice; most fitting algorithms perform much better than that. We also see that the  $\ell_1$  error of HCCROOTEDTREEFIT is comparable to that of TREEREP, while NEIGHBORJOIN performs much better than those. It tends to perform better when the graph data set is known to be more hyperbolic (or tree-like), despite no theoretical guarantees. It is, however, quite slow.
Also, we note from Table 3 that Gromov's algorithm, which solves our  $\ell_{\infty} / \ell_{\infty}$  hyperbolicity problem tends to return better output in terms of  $\ell_{\infty}$  error. On the other hand, its result on  $\ell_{1}$  error is not as good as the other algorithms. In contrast, our HCCROOTEDTREEFIT performs better on the  $\ell_{1}$  objective, which suggests that our approach to this problem is on target.
Table 3:  ${\ell }_{\infty }$  error (i.e.,max distortion)
Data set	C-ELEGAN	CS PHD	CORA	AIRPORT
O(n2log n)	HCC	0.648±0.013	3.114±0.029	18.125±0.330	28.821±0.345
O(n2)	Gromov	0.055±0.005	0.296±0.004	2.063±0.033	3.251±0.033
O(n2)	TR	0.068±0.009	0.223±0.046	0.610±0.080	0.764±0.151
O(n3)	NJ	0.336	4.659	268.45	804.67
Table 4: Running Time(s). For NJ, we implemented the naive algorithm, which is  $O(n^3)$ . We note that TREEREP produces a tree and not a set of distances; its running times excluded a step which computes the distance matrix, which takes  $O(n^2)$  time.
Initial Tree	BT(8,3)	BT(5,4)	BT(3,5)	BT(2,8)	DISEASE
n	585	776	364	511	2665
\(\|\boldsymbol{\Delta}_{r}\|_{1}/ \binom{n-1}{3}\)	0.01887±0.00378	0.01876±0.00375	0.00150±0.00036	0.00098±0.00020	0.00013±0.00010
HCC	0.00443±0.00098	0.01538±0.00733	0.04153±0.01111	0.07426±0.02027	0.00061±0.00058
Gromov	0.18225±0.00237	0.44015±0.00248	0.17085±0.00975	0.16898±0.00975	0.18977±0.00196
TR	0.01360±0.00346	0.01103±0.00336	0.06080±0.00874	0.09550±0.01887	0.00081±0.00059
NJ	0.03180±0.00767	0.06092±0.01951	0.04309±0.00521	0.04360±0.00648	0.00601±0.00281
Table 5: Average  ${\ell }_{1}$  error when  ${n}_{e} = {500}$
In analyzing the running times in Table 4, we notice that HCCROOTEDTREEFIT runs in truly  $O(n^{2}\log n)$  time. Also, its dominant part is the subroutine HCCTRIANGLE, which runs in  $O(n^{2})$ .
4.2 Synthetic data sets
In order to analyze the performance of our algorithm in a more thorough and rigorous fashion, we generate random synthetic distances with low hyperbolicity. More precisely, we construct a synthetic weighted graph from fixed balanced trees. We use  $\mathrm{BT}(r,h)$  to indicate a balanced tree with branching factor  $r$  and height  $h$  and DISEASE from [6], an unweighted tree data set. For each tree, we add edges randomly, until we reach 500 additional edges. Each added edge is given a distance designed empirically to keep the  $\delta$ -hyperbolicity bounded by a value of 0.2.
Then we measured the  $\ell_1$  error of each tree fitting algorithm (and averaged over 50 trials). Note that all rooted tree fitting algorithms use a root node (for balanced trees, we used the apex; for DISEASE, we used node 0).
For these experiments, we see quite different results in Table 5. All of these data sets are truly tree-like. Clearly, NEIGHBORJOIN performs considerably worse on these data than on the common data sets above, especially when the input comes from a tree with high branching factor (note that the branching factor of DISEASE is recorded as 6.224, which is also high). We also note that Gromov's method behaves much worse than all the other algorithms. This is possibly because Gromov's method is known to produce a non-stretching tree fit, while it is a better idea to stretch the metric in this case. The theoretical bound is still quite loose, but not as much as with the common data sets.
All of our experiments show that it is critical to quantify how "tree-like" a data set is in order to understand how well different tree fitting algorithms will perform on that data set. In other words, we cannot simply assume that a data set is generic when fitting a tree to it. Furthermore, we develop both a measure of how tree-like a data set is and an algorithm HCCROOTEDTREEFIT that leverages this behavior so as to minimize the appropriate distortion of this fit. The performance of HCCROOTEDTREEFIT and other standard tree fitting algorithms shows that commonly used data sets (especially in geometric graph neural nets) are quite far from tree-like and are not well-represented by trees, especially when compared with synthetic data sets. This suggests that we need considerably more refined geometric notions for learning tasks with these data sets.
[24] R. Sarkar, “Low distortion delaunay embedding of trees in hyperbolic plane,” in International Symposium on Graph Drawing, Springer, 2011, pp. 355–366.
[25] F. Sala, C. De Sa, A. Gu, and C. Ré, “Representation tradeoffs for hyperbolic embeddings,” in International conference on machine learning, PMLR, 2018, pp. 4460–4469.
[26] I. Chami, A. Gu, V. Chatziafratis, and C. Ré, “From trees to continuous embeddings and back: Hyperbolic hierarchical clustering,” Advances in Neural Information Processing Systems, vol. 33, pp. 15065–15076, 2020.
[27] N. Monath, M. Zaheer, D. Silva, A. McCallum, and A. Ahmed, "Gradient-based hierarchical clustering using continuous representations of trees in hyperbolic space," in Proceedings of the 25th ACM SIGKDD International Conference on Knowledge Discovery & Data Mining, 2019, pp. 714-722.
[28] M. Nickel and D. Kiela, “Poincaré embeddings for learning hierarchical representations,” Advances in neural information processing systems, vol. 30, 2017.
[29] N. Linial, E. London, and Y. Rabinovich, “The geometry of graphs and some of its algorithmic applications,” Combinatorica, vol. 15, no. 2, pp. 215–245, 1995.
[30] M. Nickel and D. Kiela, “Learning continuous hierarchies in the lorentz model of hyperbolic geometry,” in International Conference on Machine Learning, PMLR, 2018, pp. 3779–3788.
[31] H. Fournier, A. Ismail, and A. Vigneron, "Computing the gromov hyperbolicity of a discrete metric space," Information Processing Letters, vol. 115, no. 6-8, pp. 576-579, 2015.
[32] P. K. Agarwal, K. Fox, A. Nath, A. Sidiropoulos, and Y. Wang, "Computing the gromov-hausdorff distance for metric trees," ACM Transactions on Algorithms (TALG), vol. 14, no. 2, pp. 1-20, 2018.
[33] B. Nica and J. Špakula, “Strong hyperbolicity,” Groups, Geometry, and Dynamics, vol. 10, no. 3, pp. 951–964, 2016.
[34] T. Das, D. Simmons, and M. Urbanski, Geometry and dynamics in Gromov hyperbolic metric spaces. American Mathematical Soc., 2017, vol. 218.
[35] I. Abraham, M. Balakrishnan, F. Kuhn, D. Malkhi, V. Ramasubramanian, and K. Talwar, "Reconstructing approximate tree metrics," in Proceedings of the twenty-sixth annual ACM symposium on Principles of distributed computing, 2007, pp. 43-52.
6.1 Proof of Theorem 2.5
We will follow the details from [7] (and [1] to address minor issues). This is, in fact, the generic reduction method from ultrametric fitting.
Algorithm 5 Find a tree fitting given an ultrametric fitting procedure
1: procedure ULTRAFIT  
2: Input: distance function  $d$   
3: Output: ultrametric  $d_U$  which fits  $d$   
4: procedure ROOTEDTREEFIT  
5: Input: distance function  $d$  on  $\binom{X}{2}$  and base point  $w \in X$   
6: Output: (rooted) tree metric  $d_T$  which fits  $d$  and  $d(w, x) = d_T(w, x)$  for all  $x \in X$   
7: Define  $m = \max_{x \in X} d(w, x)$ ,  $c_w(x, y) = 2m - d(w, x) - d(w, y)$ , and  $\beta_x = 2(m - d(w, x))(x \in X)$   
8:  $d_{U'} = \text{ULTRAFIT}(d + c_w)$   
9: Restrict  $d_U(x, y) = \min(\max(\beta_x, \beta_y, d_{U'}(x, y)), 2m)$   
10:  $d_T = d_U - c_w$   
11: return  $d_T$
Claim: For any  $x,y\in X$ ,  $|d_U(x,y) - (d + c_w)(x,y)|\leq |d_{U'}(x,y) - (d + c_w)(x,y)|$  holds. In other words, the restriction will reduce the error.
Proof: It is enough to check the two cases when  $d_U$  differs.
Case 1:  $\max (\beta_x,\beta_y) = d_U(x,y) > d_{U'}(x,y)$ : without loss of generality, we assume that  $d_U(x,y) = \beta_x\geq \beta_y$ . We have  $(d + c_w)(x,y) = d(x,y) + c_w(x,y)\geq (d(w,y) - d(w,x)) + (2m - d(w,x) - d(w,y)) = 2m - 2d(w,x) = \beta_x$ , which shows  $(d + c_w)(x,y)\geq d_U(x,y) > d_{U'}(x,y)$ . Therefore the claim holds.
Case 2:  $2m = d_U(x,y) < d_{U'}(x,y)$ : since  $(d + c_w)(x,y) = 2m - 2gp_w(x,y) \leq 2m$ , we have  $(d + c_w)(x,y) \leq d_U(x,y) < d_{U'}(x,y)$ . Again, the claim holds.
Claim: The restriction  $d_U$  is also an ultrametric.
Proof: We need to prove  $d_U(x,y) \leq \max(d_U(x,z), d_U(y,z))$  for all  $x,y,z \in X$ . As  $U'$  is ultrametric by assumption, it is enough to check only if
$$
d _ {U} (x, y) > d _ {U ^ {\prime}} (x, y) \text {o r} \max  \left(d _ {U} (x, z), d _ {U} (y, z)\right) > \max  \left(d _ {U ^ {\prime}} (x, z), d _ {U ^ {\prime}} (y, z)\right) \text {h o l d s}.
$$
Case 1:  $d_U(x,y) > d_{U'}(x,y)$ : we have  $\max(\beta_x, \beta_y) = d_U(x,y) > d_{U'}(x,y)$ . Without loss of generality, we assume that  $d_U(x,y) = \beta_x \geq \beta_y$ . Then we have  $d_U(x,z) \geq \max(\beta_x, \beta_z) \geq \beta_x = d_U(x,y)$ , which shows  $d_U(x,y) \leq \max(d_U(x,z), d_U(y,z))$ .
Case 2:  $\max(d_U(x, z), d_U(y, z)) < \max(d_{U'}(x, z), d_{U'}(y, z))$ : we have  $d_U(x, z) < d_{U'}(x, z)$  or  $d_U(y, z) < d_{U'}(y, z)$  holds. In either case, we have the value is clipped by the maximum value  $2m$  so that  $d_U(x, y) \leq \max(d_U(x, z), d_U(y, z)) = 2m$ .
Therefore, we conclude that the stronger triangle inequality still holds, which completes the proof.
Claim: By the restriction,  $d_{T}$  satisfies tree metric.
Proof: First, we need to verify that  $d_{T}$  is a metric. First, we have
$$
\begin{array}{l} d _ {T} (x, y) = d _ {U} (x, y) - c _ {w} (x, y) \geq \max  (\beta_ {x}, \beta_ {y}) - c _ {w} (x, y) = \max  (\beta_ {x}, \beta_ {y}) - \frac {1}{2} (\beta_ {x} + \beta_ {y}) \\ = \frac {\left| \beta_ {x} - \beta_ {y} \right|}{2} = \left| d (w, x) - d (w, y) \right| \geq 0, \\ \end{array}
$$
so that  $d_{T}$  is non-negative. Next, we will prove the triangle inequality:  $d_{T}(x,z)\leq d_{T}(x,y) + d_{T}(y,z)$ . Without loss of generality, we assume that  $d_{U}(x,y)\geq d_{U}(y,z)$ . Then we have
$$
\begin{array}{l} d _ {T} (x, z) = d _ {U} (x, z) - c _ {w} (x, z) \leq \max  \left(d _ {U} (x, y), d _ {U} (y, z)\right) - c _ {w} (x, z) \\ = d _ {U} (x, y) - c _ {w} (x, y) + c _ {w} (x, y) - c _ {w} (x, z) \\ = d _ {T} (x, y) + (d (w, z) - d (w, y)) \\ \leq d _ {T} (x, y) + | d (w, z) - d (w, y) | \leq d _ {T} (x, y) + d _ {T} (y, z). \\ \end{array}
$$
Therefore,  $d_{T}$  is (non-negative) metric. To show it is a tree metric, we examine the four point condition of  $d_{T}$ . For any  $x, y, z, t \in X$ ,
$$
\begin{array}{l} d _ {T} (x, y) + d _ {T} (z, t) = \left(d _ {U} (x, y) - c _ {w} (x, y)\right) + \left(d _ {U} (z, t) - c _ {w} (z, t)\right) \\ = \left(d _ {U} (x, y) + d _ {U} (z, t)\right) - \left(c _ {w} (x, t) + c _ {w} (z, t)\right) \\ = \left(d _ {U} (x, y) + d _ {U} (z, t)\right) - \left(4 m - d (w, x) - d (w, y) - d (w, z) - d (w, t)\right), \\ \end{array}
$$
so that any pair sum of  $d_{T}$  differs from  $d_{U}$  by  $4m - d(w,x) - d(w,y) - d(w,z) - d(w,t)$ . As  $d_{U}$  is ultrametric and thus 0-hyperbolic,  $d_{T}$  is also 0-hyperbolic, as desired. Thus,  $d_{T}$  is a tree metric.
Finally, we prove that  $\ell_p$  error of  $d_T$  is bounded as desired. This can be done by
$$
\begin{array}{l} \left\| d - d _ {T} \right\| _ {p} = \left\| \left(d + c _ {w}\right) - \left(d _ {T} + c _ {w}\right) \right\| _ {p} = \left\| d _ {U} - \left(d + c _ {w}\right) \right\| _ {p} \\ \leq \left\| d _ {U ^ {\prime}} - \left(d + c _ {w}\right) \right\| _ {p} \leq \operatorname {A v g U M} _ {q} \left(d + c _ {w}\right) \cdot f (n), \\ \end{array}
$$
by assumption. For  $1 \leq q < \infty$ , we have
$$
\begin{array}{l} \frac{1}{n}\sum_{w\in X}(\operatorname {AvgUM}_{q}(d + c_{w}))^{q} = \frac{1}{n}\sum_{w\in X}\frac{1}{\binom{n}{3}}\sum_{\substack{x,y,z\in \left( \begin{array}{c}X\setminus \{w\} \\ 3 \end{array} \right)}}tp(d + c_{w};x,y,z)^{q} \\ = \frac{n - 3}{n^{2}}\sum_{w\in X}\frac{1}{\binom{n - 1}{3}}\sum_{x,y,z\in \binom {X\setminus \{w\}}{3}}2^{q}fp_{w}(d;x,y,z)^{q} \\ = 2 ^ {q} \frac {n - 3}{n} \cdot \frac {1}{\binom {n} {4}} \sum_ {x, y, z, w \in \left( \begin{array}{c} x \\ 4 \end{array} \right)} f p ^ {q} (d; x, y, z, w) \\ = 2 ^ {q} \frac {n - 3}{n} (\operatorname {A v g H y p} _ {q} (d)) ^ {q}. \\ \end{array}
$$
Therefore, there exists  $w \in X$  so that  $\mathrm{AvgUM}_q(d + c_w) \leq 2\left(\frac{n - 3}{n}\right)^{1 / q} \mathrm{AvgHyp}_q(d)$ . The  $q = \infty$  case can be separately checked.
Hence, there exists  $w \in X$  where such reduction yields a tree fitting with  $\ell_p$  error bounded by  $2\left(\frac{n - 3}{n}\right)^{1 / q} \operatorname{AvgHyp}_q(d) \cdot f(n)$ , as desired.
Note that when we use HCCULTRAfit, then  $\max (\beta_x,\beta_y)\leq d_{U'}(x,y)\leq 2m$  always hold so that the clipping is not necessary.
6.2 Proof of Theorem 2.6
Our reduction is based on the technique from [16] and Section 9 of [1]. Given  $d$  on  $X$ , we will construct a distance  $d'$  on  $Z = X \cup Y$  such that  $|X| = |Y| = n$  and
$$
d ^ {\prime} (z, w) = \left\{ \begin{array}{l l} d (z, w) & \text {i f} z, w \in X \\ M & \text {i f} z \in X, w \in Y \text {o r} z \in Y, w \in X \text {f o r a l l} z \neq w \in Z, \\ c & \text {i f} z, w \in Y \end{array} \right.
$$
for  $M$  large enough and  $c$  small enough. Then first we have
Claim: If  $1 \leq q < \infty$ , then  $\mathrm{AvgHyp}_q(d') \leq \left(\frac{1}{4} + 2^{q - 4}\right)^{1/q} \cdot \mathrm{AvgUM}_q(d)$ . For  $q = \infty$ , we have  $\mathrm{Hyp}(d') \leq 2\mathrm{UM}(d)$ .
Proof: It can be checked that if at least two of  $x, y, z, w$  is from  $Y$ , then we immediately have  $fp(d'; x, y, z, w) = 0$ . Therefore, we get
$$
\begin{array}{l} \sum_ {x, y, z, w \in \left( \begin{array}{c} Z \\ 4 \end{array} \right)} f p (d ^ {\prime}; x, y, z, w) ^ {q} = \sum_ {x, y, z, w \in \left( \begin{array}{c} X \\ 4 \end{array} \right)} f p (d ^ {\prime}; x, y, z, w) ^ {q} + \sum_ {w \in Y} \sum_ {x, y, z \in \left( \begin{array}{c} X \\ 3 \end{array} \right)} f p (d ^ {\prime}; x, y, z, w) ^ {q} \\ = \sum_ {x, y, z, w \in \left( \begin{array}{c} X \\ 4 \end{array} \right)} f p (d; x, y, z, w) ^ {q} + \sum_ {w \in Y} \sum_ {x, y, z \in \left( \begin{array}{c} X \\ 3 \end{array} \right)} t p (d; x, y, z) ^ {q} \\ = \binom {n} {4} \operatorname {A v g H y p} _ {q} (d) ^ {q} + n \binom {n} {3} \operatorname {A v g U M} _ {q} (d) ^ {q}. \\ \end{array}
$$
To bound  $\mathrm{AvgHyp}_q$ , we will use the fact that
$$
f p (d; x, y, z, w) \leq \frac {1}{2} [ t p (d; x, y, z) + t p (d; x, y, w) + t p (d; x, z, w) + t p (d; y, z, w) ].
$$
$$
\begin{array}{l} \operatorname {AvgHyp}_{q}(d)^{q} = \frac{1}{\binom{n}{4}}\sum_{\substack{x,y,z,w\in \binom {X}{4}}}fp(d;x,y,z,w)^{q} \\ \leq \frac{2^{q - 2}}{\binom{n}{4}}\sum_{x,y,z,w\in \binom {X}{4}}[tp(d;x,y,z)^{q} + tp(d;x,y,w)^{q} + tp(d;x,z,w)^{q} + tp(d;y,z,w)^{q}] \\ = \frac{2^{q - 2}}{\binom{n}{4}}\sum_{x,y,z\in \binom {X}{3}}(n - 3)tp(d;x,y,z)^{q} = \frac{2^{q}}{\binom{n}{3}}\sum_{x,y,z\in \binom {X}{3}}tp(d;x,y,z)^{q} = 2^{q}\operatorname{AvgUM}_{q}(d)^{q}. \\ \end{array}
$$
To sum up, we get
$$
\begin{array}{l} \operatorname {AvgHyp}_{q}(d^{\prime})^{q} = \frac{1}{\binom{2n}{4}}\sum_{\substack{x,y,z,w\in \binom {Z}{4}}}fp(d^{\prime};x,y,z,w)^{q} \\ = \frac {\binom {n} {4}}{\binom {2 n} {4}} \operatorname {A v g H y p} _ {q} (d) ^ {q} + \frac {n \binom {n} {3}}{\binom {2 n} {4}} \operatorname {A v g U M} _ {q} (d) ^ {q} \\ \leq \frac {1}{1 6} \operatorname {A v g H y p} _ {q} (d) ^ {q} + \frac {1}{4} \operatorname {A v g U M} _ {q} (d) ^ {q} \\ \leq \frac {2 ^ {q}}{1 6} \operatorname {A v g U M} _ {q} (d) ^ {q} + \frac {1}{4} \operatorname {A v g U M} _ {q} (d) ^ {q} = \left(\frac {1}{4} + 2 ^ {q - 4}\right) \operatorname {A v g H y p} _ {q} (d) ^ {q}. \\ \end{array}
$$
The  $q = \infty$  case can be checked separately.
Therefore, by the claim above and the assumption, we have a tree fitting  $d_T$  which fits  $d'$  with  $\| d_T - d' \|_p \leq \operatorname{AvgHyp}_q(d') \cdot f(2n)$ . Our goal is to construct a reduction to deduce an ultrametric fit  $d_U$  on  $X$ , by utilizing  $d_T$ . First,
Claim: If  $M$  and  $c$  were large and small enough respectively, then  $d_{T}(x_{1},y) + d_{T}(x_{2},y) - d_{T}(x_{1},x_{2}) \geq 2c$  holds for every  $x_{1},x_{2} \in X$  and  $y \in Y$ .