SlowGuess/NeurIPS_2023_OCR huggingface dataset:
For two graphs  $G$  and  $H$  on  $n$  and  $m$  vertices, respectively, the 1-WL test converges after at most  $\max \{n,m\}$  refinement rounds, i.e., the color partitions are stable and cannot further be refined in subsequent rounds. For  $d_{\mathsf{P},h}$ , however, it is conceivable that  $d_{\mathsf{P},h}$  still changes even after having obtained stable color partitions. More precisely, by Lemma 15,  $d_{\mathsf{P},h}$  may still increase, i.e., we have a second convergence step where the distances  $d_{\mathsf{P},h}$  converge after the color partitions have already stabilized. However, for the Prokhorov distance, we can argue that this takes, at most, polynomially many steps.
Theorem 19. Let  $G$  and  $H$  be graphs. Then,  $\delta_{\mathsf{P},\infty}(G,H)$  can be computed in polynomial time.
Proof. Let  $n$  and  $m$  be the number of vertices of  $G$  and  $H$ , respectively. Then, the masses that an IDM assigns to a color class are all of the form  $i / (n \cdot m)$  for a natural number  $i$ , which implies that the resulting Prokhorov distance between such IDMs also is of this form. This inductively yields that all entries of the distance matrices in the computation of  $\delta_{\mathbb{P},h}(G,H)$  for  $h \in \mathbb{N}$  are of this form and, with the monotonicity of Lemma 15, we get that all  $n \cdot m$  entries can increase at most  $n \cdot m$  times, i.e., the distance matrix stays constant after at most  $(n \cdot m)^2$  steps. Thus, the claim follows.
When combined with the previous analysis, this yields that  $\delta_{\mathbb{P},\infty}(G,H)$  can be computed in time  $\mathcal{O}(n^4\cdot n^7) = \mathcal{O}(n^{11})$ , where  $n$  is the maximum number of vertices in the two input graphs.
C.2.3 The unbalanced Wasserstein metric
Let us now turn our attention to our unbalanced Wasserstein metric. To this end, let  $(S,d)$  be a complete separable metric space with Borel  $\sigma$ -algebra  $\mathcal{B}$ . We first note that the Wasserstein distance of two probability measures  $\mu, \nu \in \mathcal{P}(S)$  is
$$
\mathsf {W} (\mu , \nu) := \inf  _ {\gamma \in \mathcal {C} (\mu , \nu)} \int_ {S \times S} d (x, y) d \gamma (x, y),
$$
where  $\mathcal{C}(\mu, \nu)$  is the set of all couplings of  $\mu$  and  $\nu$ , i.e., probability measures  $\gamma \in \mathcal{P}(S \times S)$  with marginals  $\mu$  and  $\nu$  or, formally,  $(p_1)_*\gamma = \mu$  and  $(p_2)_*\gamma = \nu$ . In Section 3, for finite measures  $\mu, \nu \in \mathcal{M}_{\leq 1}(S)$ , where where we assume  $\| \mu \| \geq \| \nu \|$  without loss of generality, we defined the unbalanced Wasserstein distance
$$
\mathsf {W} (\mu , \nu) := \| \mu \| - \| \nu \| + \inf  _ {\gamma \in \mathcal {M} (\mu , \nu)} \int_ {S \times S} d (x, y)   d \gamma (x, y),
$$
where  $\mathcal{M}(\mu, \nu)$  is the set of all measures  $\gamma \in \mathcal{M}_{\leq 1}(S \times S)$  such that  $(p_1)_*\gamma \leq \mu$  and  $(p_2)_*\gamma = \nu$ . We first note that  $W$  is well-defined as  $\mathcal{M}(\mu, \nu)$  is non-empty since  $\frac{1}{\|\mu\|} (\mu \times \nu) \in \mathcal{M}(\mu, \nu)$ . On probability measures, this definition coincides with the Wasserstein distance [35, Section 11.8], and on finite histograms, it coincides with the Earth Mover's Distance  $\widehat{EMD}_1$  introduced by Pele and Werman [97, 98]. To prove that  $W$  indeed is a metric on  $\mathcal{M}_{\leq 1}(S)$ , we follow the proof of Pele and Werman [97] and relate our definition of  $W$  to the classical definition on probability measures as follows: For a complete separable metric space  $(S, d)$  where any two elements have a distance at most one and a measure  $\mu \in \mathcal{M}_{\leq 1}(S, d)$  we define the space  $(S^*, d^*)$  and the probability measure  $\mu \in \mathcal{P}(S^*, d^*)$  by adding a new element  $^*$  of mass  $1 - \| \mu \|$  that has distance one to all other elements. Formally, we let  $S^* := S \cup \{*\}$ ,
$$
d ^ {*} (x, y) := \left\{ \begin{array}{l l} d (x, y) & \text {i f} x, y \in S, \\ 1 & \text {o t h e r w i s e} \end{array} \right.
$$
for all  $x,y\in S$  , and
$$
\mu^ {*} (A) := \left\{ \begin{array}{l l} \mu (A \setminus \{*\}) + (1 - \| \mu \|) & \text {i f} * \in A, \\ \mu (A) & \text {o t h e r w i s e} \end{array} \right.
$$
for every  $A \in \mathcal{B}(S^{*}, d^{*})$ . For measures obtained this way, we have the following.
Lemma 20. Let  $(S,d)$  be a complete separable metric space where any two elements have a distance at most one and  $\mu, \nu \in \mathcal{M}_{\leq 1}(S,d)$ . Then,  $\mathsf{W}(\mu^{*},\nu^{*}) = \mathsf{W}(\mu,\nu)$ .
Proof. Without loss of generality, we assume that  $\| \mu \| \geq \| \nu \|$ . To show that  $\mathsf{W}(\mu^{*},\nu^{*})\leq \mathsf{W}(\mu ,\nu)$ , we show that a  $\gamma \in \mathcal{M}(\mu ,\nu)$  yields a  $\gamma^{*}\in \mathcal{C}(\mu^{*},\nu^{*})$  such that
$$
\int_ {S ^ {*} \times S ^ {*}} d ^ {*} (x, y) d \gamma^ {*} (x, y) = \| \mu \| - \| \nu \| + \int_ {S \times S} d (x, y) d \gamma (x, y). \tag {3}
$$
To this end, we define  $\gamma^{*}\in \mathcal{C}(\mu^{*},\nu^{*})$  by
$$
\begin{array}{l} \gamma^ {*} (C) := \gamma (C \cap (S \times S)) + (\mu - (p _ {1}) _ {*} \gamma) (\{x \in S \mid (x, *) \in C \}) \\ + (1 - \| \mu \|) \mathbb {1} [ (*, *) \in C ] \\ \end{array}
$$
for every  $C \in \mathcal{B}(S \times S)$ . It is easy to verify that  $\gamma^{*}$  actually is a probability measure with marginals  $\mu^{*}$  and  $\nu^{*}$ . Then,
$$
\begin{array}{l} \int_ {S ^ {*} \times S ^ {*}} d ^ {*} (x, y) d \gamma^ {*} (x, y) = \int_ {S \times S} d ^ {*} (x, y) d \gamma^ {*} (x, y) + \int_ {\{*\} \times S} d ^ {*} (x, y) d \gamma^ {*} (x, y) \\ + \int_ {S \times \{*\}} d ^ {*} (x, y) d \gamma^ {*} (x, y) \\ + \int_ {\{*, \} \times \{*, \}} d ^ {*} (x, y) d \gamma^ {*} (x, y) \\ = \int_ {S \times S} d (x, y) d \gamma (x, y) + 0 + \| \mu - (p _ {1}) _ {*} \gamma \| + 0 \\ = \| \mu \| - \| \nu \| + \int_ {S \times S} d (x, y) d \gamma (x, y). \\ \end{array}
$$
For the other direction  $\mathsf{W}(\mu^{*},\nu^{*})\geq \mathsf{W}(\mu ,\nu)$ , we show that a  $\gamma^{*}\in \mathcal{C}(\mu^{*},\nu^{*})$  restricts to a  $\gamma \in \mathcal{M}(\mu ,\nu)$  such that (3) holds. Let  $\gamma$  denote the restriction of  $\gamma^{*}$  to  $\mathcal{B}(S\times S)$ . We prove that  $\gamma \in \mathcal{M}(\mu ,\nu)$ . First, we have
$$
(p _ {1}) _ {*} \gamma (A) = \gamma (A \times S) \leq \gamma^ {*} (A \times S ^ {*}) = (p _ {1}) _ {*} \gamma^ {*} (A) = \mu^ {*} (A) = \mu (A),
$$
and, analogously,  $(p_2)_*\gamma(A) \leq \nu(A)$  for every  $A \in \mathcal{B}(S)$ . Now, assume that  $(p_2)_*\gamma(A) < \nu(A)$  for some  $A \in \mathcal{B}(S)$ . Then,
$$
\| \nu \| = \gamma (S \times A) + \gamma (S \times \bar {A}) <   \nu (A) + \nu (\bar {A}) = \| \nu \|,
$$
which is a contradiction. Next, observe that
$$
\gamma^ {*} (\{*, S \} \times S) + \gamma^ {*} (\{*, S \} \times \{*, S \}) = 1 - \gamma^ {*} (S \times S ^ {*}) = 1 - \mu^ {*} (S) = 1 - \| \mu \|,
$$
and also  $\gamma^{*}(S\times \{*\}) + \gamma^{*}(\{*\} \times \{*\}) = 1 - \| \nu \|$ . By the previous paragraph, we have  $\gamma^{*}(S\times S) = \| \nu \|$  which yields that
$$
\gamma^ {*} (\{*, S \} \times S) + \gamma^ {*} (S \times \{*, S \}) + \gamma^ {*} (\{*, S \} \times \{*, S \}) = 1 - \| \nu \|.
$$
We get  $\gamma^{*}(\{*\} \times S) = 0$  and, hence,  $\gamma^{*}(\{*\} \times \{*\}) = 1 - \| \mu\|$  and, thus,  $\gamma^{*}(S \times \{*\}) = \| \mu\| - \| \nu\|$ . From this we obtain
$$
\begin{array}{l} \int_ {S ^ {*} \times S ^ {*}} d ^ {*} (x, y) d \gamma^ {*} (x, y) = \int_ {S \times S} d (x, y) d \gamma (x, y) + \gamma^ {*} (\{\ast \} \times S) + \gamma^ {*} (S \times \{\ast \}) \\ = \| \mu \| - \| \nu \| + \int_ {S \times S} d (x, y) d \gamma (x, y). \\ \end{array}
$$
Corollary 21. Let  $(S,d)$  be a separable metric space. Then,  $\mathsf{W}$  is a metric on  $\mathcal{M}_{\leq 1}(S,d)$ .
Proof. Follows immediately from Lemma 20 and the fact that  $\mathsf{W}$  is a metric on  $\mathcal{P}(S^*, d^*)$ , cf. [35, Lemma 11.8.3].
To show that  $W$  also metrizes the weak topology, we show that it is upper-bounded by the Prokhorov metric and lower-bounded by another metric that we define in the following. For two  $\mu, \nu \in \mathcal{M}_{\leq 1}(S)$ , let
$$
\mathsf{K}(\mu ,\nu):= \sup_{\substack{\| f\|_{L}\leq 1,\\ \| f\|_{\infty}\leq 1}}\Bigl|\int fd\mu -\int fd\nu \Bigr|\quad \text{and}\quad \mathsf{BL}(\mu ,\nu):= \sup_{\| f\|_{BL}\leq 1}\Bigl|\int fd\mu -\int fd\nu \Bigr|
$$
be the Kantorovich-Rubinshtein distance and the Bounded-Lipschitz distance of  $\mu$  and  $\nu$ , respectively, where  $\|f\|_{BL} \coloneqq \|f\|_L + \|f\|_\infty$  for  $f \colon S \to \mathbb{R}$ . We clearly have  $\mathrm{BL}(\mu, \nu) \leq \mathsf{K}(\mu, \nu) \leq 2\mathrm{BL}(\mu, \nu)$ . If  $(S, d)$  is separable, then  $\mathsf{K}$  and  $\beta$  metrize the weak topology [17, Theorem 8.3.2].
We lower-bound the unbalanced Wasserstein distance  $W$  by the Kantorovich-Rubinshtein distance  $K$  and upper-bound it by the Prokhorov distance  $P$  (with a factor of two). This directly implies that  $W$  metrizes the weak topology. These inequalities for probability measures are easily found in the literature, see Dudley [35], and we generalize them to finite measures of total mass at most one. There are two ways to go on about this. First, one could use Lemma 20 and show that the analogous statement holds for the Prokhorov distance  $P$ ; then, these inequalities follow from the ones for probability measures. Secondly, one can prove these inequalities directly, which is what we do here as the proofs provide a better understanding of these metrics, although they are not as straightforward as one might expect. In particular, the proof of upper-bounding the Wasserstein distance by the Prokhorov distance in [35] is quite complicated, and we follow the simpler proofs outlined in Schay [106] and García-Palomares and Evarist Giné [45], which use the duality of linear programming. We remark that the inequalities between the Prokhorov distance  $P$  and the unbalanced Wasserstein distance  $W$  presented in Section 3 are a special case of the following lemma.
Lemma 22. Let  $(S,d)$  be a complete separable metric space. Then, for all  $\mu ,\nu \in \mathcal{M}_{\leq 1}(S)$
$$
\mathsf {B L} (\mu , \nu) \leq \mathsf {K} (\mu , \nu) \leq \mathsf {W} (\mu , \nu) \leq 2 \mathsf {P} (\mu , \nu) \leq 4 \sqrt {\mathsf {B L} (\mu , \nu)}.
$$
Proof. In the following, we assume  $\| \mu \| \geq \| \nu \|$  without loss of generality. The first inequality follows immediately from the definition. For the second inequality, we first prove the following claim.
Claim 23. Let  $f\colon S\to \mathbb{R}^n$  be Lipschitz. Then,
$$
\left\| \int_ {S} f d \mu - \int_ {S} f d \nu \right\| _ {2} \leq \| f \| _ {\infty} \cdot \left(\| \mu \| - \| \nu \|\right) + \| f \| _ {L} \cdot \int_ {S \times S} d (x, y) d \gamma (x, y)
$$
for every  $\gamma \in \mathcal{M}(\mu, \nu)$ .
Proof. Let  $\gamma \in \mathcal{M}(\mu, \nu)$ . Then,
$$
\begin{array}{l} \left\| \int_ {S} f d \mu - \int_ {S} f d \nu \right\| _ {2} = \left\| \int_ {S} f d \mu - \int_ {S} f d (p _ {1}) _ {*} \gamma + \int_ {S} f d (p _ {1}) _ {*} \gamma - \int_ {S} f d \nu \right\| _ {2} \\ \leq \left\| \int_ {S} f d (\mu - (p _ {1}) _ {*} \gamma) \right\| _ {2} + \left\| \int_ {S} f d (p _ {1}) _ {*} \gamma - \int_ {S} f d (p _ {2}) _ {*} \gamma \right\| _ {2} \\ = \left\| \int_ {S} f d (\mu - (p _ {1}) _ {*} \gamma) \right\| _ {2} + \left\| \int_ {S \times S} (f (x) - f (y)) d \gamma (x, y) \right\| _ {2} \\ \leq \int_ {S} \| f \| _ {2} d (\mu - (p _ {1}) _ {*} \gamma) + \int_ {S \times S} \| f (x) - f (y) \| _ {2} d \gamma (x, y) \\ \leq \int_ {S} \| f \| _ {\infty} d (\mu - (p _ {1}) _ {*} \gamma) + \int_ {S \times S} \| f \| _ {L} \cdot d (x, y) d \gamma (x, y) \\ = \| f \| _ {\infty} \cdot \| \mu - (p _ {1}) _ {*} \gamma \| + \| f \| _ {L} \cdot \int_ {S \times S} d (x, y) d \gamma (x, y) \\ = \| f \| _ {\infty} \cdot (\| \mu \| - \| \nu \|) + \| f \| _ {L} \cdot \int_ {S \times S} d (x, y) d \gamma (x, y). \\ \end{array}
$$
The claim implies that, for an  $f \colon S \to \mathbb{R}$  with  $\| f \|_L \leq 1$  and  $\| f \|_\infty \leq 1$ , we have  $\left| \int_S f d\mu - \int_S f d\nu \right| \leq W(\mu, \nu)$ , and since this holds for every such  $f$ , we get  $K(\mu, \nu) \leq W(\mu, \nu)$ .
For the third inequality, we follow Schay [106] and García-Palomares and Evarist Gine [45], who proved this inequality for probability measures by using the duality of linear programming in the finite case and then lifting this result to the infinite case. Note that we already used this connection to linear programming in as Claim 17 to show that the Prokhorov metric is efficiently computable in Theorem 16.
Assume that  $\| \mu \| \geq \| \nu \|$  without loss of generality. If  $S$  is finite (or  $\mu$  and  $\nu$  are finitely supported), we use that  $\mathsf{P}(\mu, \nu) = \inf \{\varepsilon > 0 \mid \rho(\varepsilon) \leq \varepsilon\}$  for the function  $\rho$  defined in the proof of Theorem 16. Claim 17 expresses the value  $\rho(\varepsilon)$  for an  $\varepsilon > 0$  as a linear program and we can interpret the solution to this linear program as a measure  $\gamma_{\varepsilon} \in \mathcal{M}(\mu, \nu)$  that satisfies  $\rho(\varepsilon) = \| \mu \| - \gamma_{\varepsilon}(\Delta_{\varepsilon})$ , where  $\Delta_{\varepsilon} := \{(x, y) \in S \times S \mid d(x, y) \leq \varepsilon\}$ . Choose a sequence  $\varepsilon_{n}$  with  $\varepsilon_{n} \downarrow \mathsf{P}(\mu, \nu)$  and  $\rho(\varepsilon_{n}) \leq \varepsilon_{n}$ . Then,
$$
\varepsilon_ {n} \geq \rho (\varepsilon_ {n}) = \| \mu \| - \gamma_ {\varepsilon_ {n}} (\varDelta_ {\varepsilon_ {n}}) = \| \mu \| - \| \gamma_ {\varepsilon_ {n}} \| + \gamma_ {\varepsilon_ {n}} \left(\overline {{\varDelta_ {\varepsilon_ {n}}}}\right) = \| \mu \| - \| \nu \| + \gamma_ {\varepsilon_ {n}} \left(\overline {{\varDelta_ {\varepsilon_ {n}}}}\right)
$$
and, hence,
$$
\begin{array}{l} \mathrm {W} (\mu , \nu) \leq \| \mu \| - \| \nu \| + \int_ {S \times S} d (x, y) d \gamma_ {\varepsilon_ {n}} (x, y) \\ = \| \mu \| - \| \nu \| + \int_ {\Delta_ {\varepsilon_ {n}}} d (x, y) d \gamma_ {\varepsilon_ {n}} (x, y) + \int_ {\overline {{\Delta_ {\varepsilon_ {n}}}}} d (x, y) d \gamma_ {\varepsilon_ {n}} (x, y) \\ \leq \| \mu \| - \| \nu \| + \varepsilon_ {n} \cdot \| \gamma_ {\varepsilon_ {n}} \| + \| d \| _ {\infty} \cdot \gamma_ {\varepsilon_ {n}} \left(\overline {{\Delta_ {\varepsilon_ {n}}}}\right) \leq 2 \cdot \varepsilon_ {n}, \\ \end{array}
$$
which yields that  $\mathsf{W}(\mu ,\nu)\leq 2\mathsf{P}(\mu ,\nu)$
We can also consider the limit of the  $\gamma_{\varepsilon_n}$ . More precisely, since  $\mathcal{P}(S\times S)$  is compact, the sequence  $\gamma_{\varepsilon_n}$ , by possibly considering a subsequence, converges to a measure  $\gamma$  of the same total mass, which is  $\| \nu \|$ . For this, note that results for probability measures apply since we can just rescale a sequence since all measures have the same total mass. We then have  $\gamma \in \mathcal{M}(\mu ,\nu)$ , cf. the case for  $S$  infinite, and for  $\varepsilon >\mathsf{P}(\mu ,\nu)$ ,
$$
\begin{array}{l} \| \mu \| - \| \nu \| + \gamma (\overline {{\Delta_ {\varepsilon}}}) \leq \| \mu \| - \| \nu \| + \lim  _ {n \rightarrow \infty} \inf  _ {\varepsilon_ {n}} \gamma_ {\varepsilon_ {n}} (\overline {{\Delta_ {\varepsilon}}}) \\ \leq \| \mu \| - \| \nu \| + \liminf _ {n \to \infty} \gamma_ {\varepsilon_ {n}} \left(\overline {{\Delta_ {\varepsilon_ {n}}}}\right) \leq \liminf _ {n \to \infty} \varepsilon_ {n} = \mathrm {P} (\mu , \nu), \\ \end{array}
$$
where the first inequality holds by the Portmanteau theorem, which again implies  $\mathsf{W}(\mu ,\nu)\leq 2\mathsf{P}(\mu ,\nu)$  as before.
The infinite case works by approximating  $\mu$  and  $\nu$  by finite measures and is mostly analogous to [45] as we can rescale a sequence of measures of the same total mass to probability measures. More precisely, one weakly approximates  $\mu$  and  $\nu$  by sequences of measures  $\mu_{n}$  and  $\nu_{n}$  of total mass  $\| \mu \|$  and  $\| \nu \|$ , respectively, supported by the finite set  $S_{n}$  for  $n\geq 1$ . Then,  $\lim_{n\to \infty}\mathsf{P}(\mu_n,\nu_n) = \mathsf{P}(\mu ,\nu)$  by the triangle inequality.
For  $n \geq 0$ , take  $\gamma_{n} \in \mathcal{M}(\mu_{n}, \nu_{n})$  of total mass  $\|\nu\|$  for  $\mu_{n}$  and  $\nu_{n}$  as defined in the finite case, i.e., we have  $\|\mu\| - \|\nu\| + \gamma(\overline{\Delta_{\varepsilon}}) \leq \mathsf{P}(\mu_{n}, \nu_{n})$  for every  $\varepsilon > \mathsf{P}(\mu_{n}, \nu_{n})$ . Since  $\mu_{n}$  and  $\nu_{n}$  are uniformly tight as weakly convergent sequences, the sequence  $\gamma_{n}$  is also uniformly tight and, by possibly considering a subsequence, converges to a measure  $\gamma$  of total mass  $\|\nu\|$ . By continuity of  $p_{2}$ , we then have that  $(p_{2})_{*}\gamma_{n}$  converges to  $(p_{2})_{*}\gamma$ . Since  $(p_{2})_{*}\gamma_{n} = \nu_{n}$  converges to  $\nu$ , we get that  $(p_{2})_{*}\gamma = \nu$ . Moreover, one can show that  $(p_{2})_{*}\gamma_{n} \leq \mu_{n}$  implies that  $(p_{2})_{*}\gamma \leq \mu$ : For a closed set  $C \in \mathcal{B}(S)$  and an  $\eta > 0$ , approximate  $C$  by the Lipschitz function  $f(x) := \max\{0, 1 - \frac{d(x, C)}{\eta}\}$ . Then,  $\mathbf{1}_{C} \leq f \leq \mathbf{1}_{C^{\eta}}$  and, hence,
$$
\begin{array}{l} (p _ {2}) _ {*} \gamma (C) = \int_ {S} \mathbf {1} _ {C} d (p _ {2}) _ {*} \gamma \leq \int_ {S} f d (p _ {2}) _ {*} \gamma = \lim  _ {n \rightarrow \infty} \int_ {S} f d (p _ {2}) _ {*} \gamma_ {n} \\ \leq \lim  _ {n \rightarrow \infty} \int_ {S} f d \mu_ {n} \\ = \int_ {S} f d \mu \\ \leq \int_ {S} \mathbf {1} _ {C ^ {\eta}} d \mu = \mu (C ^ {\eta}). \\ \end{array}
$$
Since this holds for every  $\eta > 0$  and  $C$  is closed, we get  $(p_2)_*\gamma(C) \leq \mu(C)$ . Then, since  $(p_2)_*\gamma$  is regular by Ulam's theorem, we get
$$
(p _ {2}) _ {*} \gamma (A) = \sup  \left\{\left(p _ {2}\right) _ {*} \gamma (K) \mid K \text {c o m p a c t}, K \subseteq A, K \in \mathcal {B} (S) \right\} \leq \mu (A)
$$
for every  $A\in \mathcal{B}(S)$ . All in all, we have  $\gamma \in \mathcal{M}(\mu ,\nu)$
For every  $\varepsilon >\mathsf{P}(\mu ,\nu)$ , we have  $\varepsilon >\mathsf{P}(\mu_n,\nu_n)$  if  $n$  is large enough since  $\mathsf{P}(\mu_n,\nu_n)$  converges to  $\mathsf{P}(\mu ,\nu)$ . Then,
$$
\| \mu \| - \| \nu \| + \gamma (\overline {{\Delta_ {\varepsilon}}}) \leq \| \mu \| - \| \nu \| + \lim  _ {n \to \infty} \inf  _ {\gamma_ {n} (\overline {{\Delta_ {\varepsilon}}})} \gamma_ {n} (\overline {{\Delta_ {\varepsilon}}}) \leq \lim  _ {n \to \infty} \inf  _ {\gamma_ {n} (\overline {{\Delta_ {\varepsilon}}})} \mathsf {P} (\mu_ {n}, \nu_ {n}) = \mathsf {P} (\mu , \nu),
$$
where the first inequality follows from the Portmanteau theorem. Then, we get
$$
\mathsf {W} (\mu , \nu) \leq \| \mu \| - \| \nu \| + \varepsilon \cdot \| \gamma \| + \| d \| _ {\infty} \cdot \gamma \left(\overline {{\Delta_ {\varepsilon}}}\right) \leq \varepsilon + \mathsf {P} (\mu , \nu),
$$
similarly to the finite case. Since this holds for every  $\varepsilon >\mathsf{P}(\mu ,\nu)$ , the claim follows.
For the last inequality, we show that  $\mathsf{P}(\mu ,\nu)\leq 2\sqrt{\mathrm{BL}(\mu,\nu)}$  by following the proof of [35, Theorem 11.3.3] for probability measures. We have
$$
\mathrm {P} (\mu , \nu) = \inf  \left\{\varepsilon > 0 \mid \mu (A) \leq \nu \left(A ^ {\varepsilon}\right) + \varepsilon \text {f o r e v e r y} A \in \mathcal {B} (S) \right\}
$$
and fix an  $A \in \mathcal{B}(S)$  and an  $\varepsilon > 0$ . Let  $f(x) \coloneqq \max \{0, 1 - \frac{d(x, A)}{\varepsilon}\}$ . Then,  $\| f \|_{BL} \leq 1 + \frac{1}{\varepsilon}$  and, hence,
$$
\begin{array}{l} \mu (A) \leq \int_ {S} f d \mu = \int_ {S} f d \nu + \left(\int_ {S} f d \mu - \int_ {S} f d \nu\right) \\ \leq \int_ {S} f d \nu + \| f \| _ {B L} \cdot \mathsf {B L} (\mu , \nu) \\ \leq \int_ {S} f d \nu + \left(1 + \frac {1}{\varepsilon}\right) \cdot \mathsf {B L} (\mu , \nu) \leq \nu (A ^ {\varepsilon}) + \left(1 + \frac {1}{\varepsilon}\right) \cdot \mathsf {B L} (\mu , \nu), \\ \end{array}
$$
which implies that  $\mathsf{P}(\mu, \nu) \leq \max \left\{\varepsilon, \left(1 + \frac{1}{\varepsilon}\right) \cdot \mathsf{BL}(\mu, \nu)\right\}$ . For  $\varepsilon := \sqrt{\mathsf{BL}(\mu, \nu)}$ , this yields that  $\mathsf{P}(\mu, \nu) \leq \mathsf{BL}(\mu, \nu) + \sqrt{\mathsf{BL}(\mu, \nu)}$ . Hence, if  $\mathsf{BL}(\mu, \nu) \leq 1$ , then  $\mathsf{P}(\mu, \nu) \leq 2 \cdot \sqrt{\mathsf{BL}(\mu, \nu)}$ . If  $\mathsf{BL}(\mu, \nu) > 1$ , then  $\mathsf{P}(\mu, \nu) \leq 2 \cdot \sqrt{\mathsf{BL}(\mu, \nu)}$  trivially holds since  $\mathsf{P}(\mu, \nu) \leq 1$  as  $\mu$  and  $\nu$  have total mass at most one.
Lemma 24. Let  $0 \leq h \leq \infty$ . The metric  $d_{\mathbb{W},h}$  is well-defined and metrizes the topology of  $\mathbb{M}_h$ . The metric  $\delta_{\mathbb{W},h}$  is well-defined and metrizes the topology of  $\mathcal{P}(\mathbb{M}_h)$ .
Proof. By Theorem 13 and Lemma 22, for a complete separable metric space  $(S,d)$ , we have that  $(\mathcal{M}(S),W)$  is a complete separable metric space and convergence in  $W$  is equivalent to weak convergence of measures. Then, the proof is analogous to Lemma 14.
C.2.4 Computability of the unbalanced Wasserstein metric
It only remains to argue that  $d_{\mathbb{W},h}$  and  $\delta_{\mathbb{W},h}$  are polynomial-time computable. This can be done in the same way as in Theorem 16, i.e., one again constructs a matrix of distances that one updates while running the 1-WL in parallel on the two input graphs. Here, the metric  $W$  can be computed in polynomial-time by using the same flow network [98] as Chen et al. [26] did in their proof for the polynomial-time computability of their Weisfeiler-Leman distance. Following their arguments, one then obtains a running time of  $\mathcal{O}(h \cdot n^5 \cdot \log n)$  for  $\delta_{\mathbb{W},h}$ , where  $h \in \mathbb{N}$  and  $n$  is the maximum number of vertices in the two input graphs.
For  $d_{\mathbb{W},\infty}$  and  $\delta_{\mathbb{W},\infty}$ , in contrast to Theorem 16, we cannot argue that all distances are of the form  $i / (n\cdot m)$ , where  $n$  and  $m$  are the numbers of vertices of the input graphs: with every iteration, we possibly get an additional factor of  $1 / (n\cdot m)$ . However, we can start rounding the distances after  $\log (1 / \varepsilon)$  iterations to integer multiples of  $1 / (n\cdot m)^{\log_2(1 / \varepsilon)}$ , which results in an additive error of  $\varepsilon$ .
C.2.5 Continuity of message-passing graph neural networks
It remains to prove Lemma 3. Recall that, for an  $L$ -layer MPNN model  $\varphi = (\varphi_{i})_{i=0}^{L}$ , we inductively defined the Lipschitz constant  $C_{\varphi} \geq 0$  of  $\varphi$  by  $C_{\varphi_{0}} := 0$  for  $t = 0$  and
$$
C _ {\boldsymbol {\varphi} _ {t}} := \left\| \varphi_ {t} \right\| _ {L} \cdot \left(\left\| \mathbf {h} _ {-} ^ {(t - 1)} \right\| _ {\infty} + C _ {\boldsymbol {\varphi} _ {t - 1}}\right)
$$
for  $t > 0$ . If additionally  $\psi$  is Lipschitz, then
$$
C _ {(\boldsymbol {\varphi}, \psi)} := \| \psi \| _ {L} \cdot \left(\| \mathbf {h} _ {-} ^ {(L)} \| _ {\infty} + C _ {\boldsymbol {\varphi}}\right).
$$
Proof. We first note that, by Claim 23, for a complete separable metric space  $(S,d)$  and a Lipschitz function  $f\colon S\to \mathbb{R}^n$  , we have
$$
\left\| \int_ {S} f d \mu - \int_ {S} f d \nu \right\| _ {2} \leq \| f \| _ {B L} \cdot \mathsf {W} (\mu , \nu).
$$
for all  $\mu, \nu \in \mathcal{M}_{\leq 1}(S)$ . Let us now prove the first inequality by induction on  $L$ . For  $L = 0$ , the statement trivially holds since  $\mathbb{M}_0$  is the one-point space. For the inductive step, we have