SlowGuess/NeurIPS_2023_OCR huggingface dataset:
We calculate  $C_{2,4}(u,v)$  as following,
$$
C _ {2, 4} (u, v) = P _ {2} (u, v) P _ {4} (u, v) - \# (\mathrm {b}) - \# (\mathrm {c}) - \# (\mathrm {d}), \tag {89}
$$
where  $\# (\mathrm{b}),\# (\mathrm{c})$  and  $\# (\mathrm{d})$  are the numbers of substructures illustrated in Figure 6b, 6c and 6d, respectively. In those figures, we always assume that  $u\to x\to y\to z\to v$  is a 4-path and  $u\rightarrow t\rightarrow v$  is a 2-path. Since every 4-path  $u\rightarrow x\rightarrow y\rightarrow z\rightarrow v$  and every 2-path  $u\rightarrow t\rightarrow v$  with  $t\neq x,t\neq y$  and  $t\neq z$  contribute one count to  $C_{2,4}(u,v)$ , it is clear that (89) gives the correct number  $C_{2,4}(u,v)$ .
We now calculate  $\# (\mathbf{b}),\# (\mathbf{c})$  and  $\# (\mathrm{d})$  .For  $\# (\mathbf{b})$  ,we have
$$
\# (\mathfrak {b}) = \sum_ {x \in \mathcal {N} _ {1} (u) \cap \mathcal {N} _ {1} (v)} P _ {3} (x, v) - \# (\mathfrak {b}, u = y) - \# (\mathfrak {b}, u = z). \tag {90}
$$
Here,  $\# (\mathbf{b},u = y)$  or  $\# (\mathbf{b},u = z)$  is the count of substructure obtained by coalescing nodes  $u,y$  or  $u,z$  in Figure 6b, while keeping  $y\neq v$  and  $x\neq z$ . It is easy to see that
$$
\# (\mathrm {b}, u = y) = P _ {2} (u, v) \left(P _ {2} (u, v) - 1\right), \tag {91}
$$
$$
\# (\mathsf {b}, u = z) = 1 _ {d (u, v) = 1} \sum_ {x \in \mathcal {N} _ {1} (u) \cap \mathcal {N} _ {1} (v)} \left(P _ {2} (u, x) - 1\right). \tag {92}
$$
The count  $\# (\mathrm{d})$  can be calculated analogously, and we summarize the results below.
$$
\begin{array}{l} \# (\mathfrak {b}) + \# (\mathfrak {d}) = \sum_ {x \in \mathcal {N} _ {1} (u) \cap \mathcal {N} _ {1} (v)} \left(P _ {3} (x, v) + P _ {3} (u, x)\right) - 2 P _ {2} (u, v) \left(P _ {2} (u, v) - 1\right) \\ - 1 _ {d (u, v) = 1} \sum_ {x \in \mathcal {N} _ {1} (u) \cap \mathcal {N} _ {1} (v)} \left(P _ {2} (u, x) + P _ {2} (x, v) - 2\right). \tag {93} \\ \end{array}
$$
By Lemmas C.7, C.10 and C.12, there exist 2-DRFWL(2) tests that assign the numbers  $P_{2}(u,v)P_{4}(u,v)$  and  $\# (\mathbf{b}) + \# (\mathbf{d})$  to  $W^{(T)}(u,v)$  respectively, for some integer  $T\geqslant 4$  and for all pairs  $(u,v)$  with  $d(u,v) = 1$  or  $d(u,v) = 2$ . Therefore, both
$$
\sum_ {v \in \mathcal {N} _ {1} (u)} P _ {2} (u, v) P _ {4} (u, v) + \sum_ {v \in \mathcal {N} _ {2} (u)} P _ {2} (u, v) P _ {4} (u, v)
$$
$$
\sum_ {v \in \mathcal {N} _ {1} (u)} (\# (\mathbf {b}) + \# (\mathbf {d})) + \sum_ {v \in \mathcal {N} _ {2} (u)} (\# (\mathbf {b}) + \# (\mathbf {d}))
$$
can be assigned by a specific 2-DRFWL(2) test  $q$  to  $W^{(T)}(u, u)$  for some  $T \geqslant 5$  and for all nodes  $u$ . To prove the lemma it now suffices to show that
$$
\sum_ {v \in \mathcal {N} _ {1} (u)} \# (\mathfrak {c}) + \sum_ {v \in \mathcal {N} _ {2} (u)} \# (\mathfrak {c})
$$
can be assigned by a 2-DRFWL(2) test to  $W^{(T)}(u, u)$  for some  $T \geqslant 5$  and for all nodes  $u$ . We calculate  $\#(\mathfrak{c})$  as following,
$$
\begin{array}{l} \# (\mathfrak {c}) = \sum_ {x \in \mathcal {N} _ {1} (u) \cap \mathcal {N} _ {1} (v)} P _ {2} (u, x) P _ {2} (x, v) - \# (\mathfrak {c}, u = z) - \# (\mathfrak {c}, x = v) - \# (\mathfrak {c}, x = z) \\ - \# (c, u = z, x = v). \tag {94} \\ \end{array}
$$
Here  $\# (\mathbf{c},u = z)$  is the count of substructure obtained by coalescing nodes  $u,z$  in Figure 6c, while keeping  $x\neq v$ . The counts  $\# (\mathbf{c},x = v)$ ,  $\# (\mathbf{c},x = z)$  and  $\# (\mathbf{c},u = z,x = v)$  can be understood analogously, but one needs to notice that when counting  $\# (\mathbf{c},x = v)$  we keep  $u\neq z$ . We have
$$
\# (\mathfrak {c}, u = z) = 1 _ {d (u, v) = 1} \sum_ {z \in \mathcal {N} _ {1} (u) \cap \mathcal {N} _ {1} (v)} \left(P _ {2} (u, z) - 1\right), \tag {95}
$$
$$
\# (\mathrm {c}, x = v) = 1 _ {d (u, v) = 1} C C _ {1} (v, u), \tag {96}
$$
$$
\# (\mathrm {c}, u = z, x = v) = 1 _ {d (u, v) = 1} P _ {2} (u, v), \tag {97}
$$
$$
\sum_ {v \in \mathcal {N} _ {1} (u)} \# (\mathrm {c}, x = z) + \sum_ {v \in \mathcal {N} _ {2} (u)} \# (\mathrm {c}, x = z) = C C _ {1} (u). \tag {98}
$$
By Lemmas C.7, C.17 and C.18, after summing over all nodes  $v \in \mathcal{N}_1(u) \cup \mathcal{N}_2(u)$ , each of the terms in (94) can be assigned by a 2-DRFWL(2) test to  $W^{(T)}(u,u)$ , for some  $T \geqslant 5$  and for all nodes  $u$ . Therefore, we have finally reached the end of the proof.
We are now in a position to give the proofs for Theorems 4.4, 4.5, 4.6 and 4.7.
We restate Theorem 4.4 as following.
Theorem C.20. 2-DRFWL(2) GNNs can node-level count 2, 3, 4-paths.
Proof. By Lemma C.5, it suffices to prove that for each  $k = 2,3,4$ , there exists a 2-DRFWL(2) test  $q$  such that for any graph  $G \in \mathcal{G}$  and for any node  $u \in \mathcal{V}_G$ ,  $q$  assigns
$$
W ^ {(T)} (u, u) = P _ {k} (u), \tag {99}
$$
In the following proofs, we no longer care the exact value of  $T$ ; instead, we are only interested in whether a graph property can be calculated by a 2-DRFWL(2) test, i.e. there exists a finite integer  $T$  and a subset of 2-DRFWL(2) colors (for example,  $W^{(T)}(u,u), u \in \mathcal{V}_G$  for node-level properties, or  $W^{(T)}(u,v), d(u,v) \leqslant 2$  for pair-level properties) that the subset of 2-DRFWL(2) colors gives exactly the values of the graph property, at the  $T$ -th iteration.
For  $k = 2$
$$
P _ {2} (u) = \sum_ {v \in \mathcal {N} _ {1} (u)} P _ {2} (u, v) + \sum_ {v \in \mathcal {N} _ {2} (u)} P _ {2} (u, v). \tag {100}
$$
But by Lemma C.7, there exists a 2-DRFWL(2) test  $q$  and an integer  $T$  such that (39) holds for all pairs  $(u,v)$  with  $d(u,v) = 1$  or  $d(u,v) = 2$ . Therefore, at the  $(T + 1)$ -th iteration,  $q$  can assign  $W^{(T + 1)}(u,u) = P_2(u)$  using (100).
$$
P _ {3} (u) = \sum_ {v \in \mathcal {N} _ {1} (u)} P _ {3} (u, v) + \sum_ {v \in \mathcal {N} _ {2} (u)} P _ {3} (u, v) + \sum_ {v \in \mathcal {N} _ {3} (u)} P _ {3} (u, v). \tag {101}
$$
Using Lemma C.10 and a similar argument to above, the first two terms of (101) can be calculated by a 2-DRFWL(2) test. For the last term of (101), we notice that
$$
\begin{array}{l} \sum_ {v \in \mathcal {N} _ {3} (u)} P _ {3} (u, v) = \sum_ {v \in \mathcal {N} _ {3} (u)} W _ {3} (u, v) \\ = W _ {3} (u) - W _ {3} (u, u) - \sum_ {v \in \mathcal {N} _ {1} (u)} W _ {3} (u, v) - \sum_ {v \in \mathcal {N} _ {2} (u)} W _ {3} (u, v). \tag {102} \\ \end{array}
$$
By Lemma C.14,  $W_{3}(u)$  can be calculated by a 2-DRFWL(2) test. From the proof of Lemma C.10, one can see that  $W_{3}(u,v)$  can be calculated by a 2-DRFWL(2) test, for  $d(u,v) = 1$  or  $d(u,v) = 2$ . Therefore, the last two terms of (102) can also be calculated by a 2-DRFWL(2) test. Since  $W_{3}(u,u) = 2C_{3}(u)$ , it can be seen from Lemma C.11 that this term can also be calculated by a 2-DRFWL(2) test. Therefore, we conclude that  $\sum_{v\in \mathcal{N}_{3}(u)}P_{3}(u,v)$ , thus  $P_{3}(u)$ , can be calculated by a 2-DRFWL(2) test.
$$
P _ {4} (u) = \sum_ {v \in \mathcal {N} _ {1} (u)} P _ {4} (u, v) + \sum_ {v \in \mathcal {N} _ {2} (u)} P _ {4} (u, v) + \sum_ {v \in \mathcal {N} _ {3} (u)} P _ {4} (u, v) + \sum_ {v \in \mathcal {N} _ {4} (u)} P _ {4} (u, v). \tag {103}
$$
Using Lemma C.12 and a similar argument to above, the first two terms of (103) can be calculated by a 2-DRFWL(2) test. Like in the  $k = 3$  case, we treat the last two terms of (103) as following,
$$
\begin{array}{l} \sum_ {v \in \mathcal {N} _ {3} (u)} P _ {4} (u, v) + \sum_ {v \in \mathcal {N} _ {4} (u)} P _ {4} (u, v) = \sum_ {v \in \mathcal {N} _ {3} (u)} W _ {4} (u, v) + \sum_ {v \in \mathcal {N} _ {4} (u)} W _ {4} (u, v) \\ = W _ {4} (u) - W _ {4} (u, u) \\ - \sum_ {v \in \mathcal {N} _ {1} (u)} W _ {4} (u, v) - \sum_ {v \in \mathcal {N} _ {2} (u)} W _ {4} (u, v). \tag {104} \\ \end{array}
$$
By Lemmas C.13 and C.14, the terms  $W_{4}(u), \sum_{v \in \mathcal{N}_{1}(u)} W_{4}(u,v)$  and  $\sum_{v \in \mathcal{N}_{2}(u)} W_{4}(u,v)$  can be calculated by 2-DRFWL(2) tests. Moreover, it is easy to verify that
$$
W _ {4} (u, u) = 2 C _ {4} (u) + \left(\deg (u)\right) ^ {2} + P _ {2} (u). \tag {105}
$$
Therefore, by Lemmas C.7, C.8 and C.15,  $W_{4}(u,u)$  can also be calculated by a 2-DRFWL(2) test. Summarizing the results above, we have proved that  $P_{4}(u)$  can be calculated by a 2-DRFWL(2) test.
We restate Theorem 4.5 as following.
Theorem C.21. 2-DRFWL(2) GNNs can node-level count 3, 4, 5, 6-cycles.
Proof. By Lemma C.5, it suffices to prove that for each  $k = 3,4,5,6$ ,  $C_k(u)$  can be calculated by a 2-DRFWL(2) test. From Lemmas C.11, C.15, C.16 and C.19, the above statement is true.
We restate Theorem 4.6 as following.
Theorem C.22. 2-DRFWL(2) GNNs can node-level count tailed triangles, chordal cycles and triangle-rectangles.
Proof. By Lemmas C.17 and C.18, and using a similar argument to above, it is easy to prove that 2-DRFWL(2) GNNs can node-level count chordal cycles and triangle-rectangles. To see why 2-DRFWL(2) GNNs can node-level count tailed triangles, we only need to give a 2-DRFWL(2) test  $q$  that assigns
$$
W ^ {(T)} (u, u) = C (\text {t a i l e d t r i a n g l e}, u, G), \quad \forall u \in \mathcal {V} _ {G}, \tag {106}
$$
for some integer  $T$ . Actually, we have
$$
C (\text {t a i l e d t r i a n g l e}, u, G) = \sum_ {v \in \mathcal {N} _ {1} (u)} \left(C _ {3} (v) - P _ {2} (u, v)\right), \tag {107}
$$
or in a symmetric form,
$$
C (\text {t a i l e d t r i a n g l e}, u, G) = \sum_ {v \in \mathcal {N} _ {1} (u)} \left(C _ {3} (u) + C _ {3} (v) - P _ {2} (u, v)\right) - C _ {3} (u) \deg (u). \tag {108}
$$
Using this formula, along with Lemmas C.7, C.8 and C.11, it is straightforward to construct the 2-DRFWL(2) test  $q$  that satisfies (106), as long as  $T \geqslant 3$ . Therefore, 2-DRFWL(2) GNNs can also node-level count tailed triangles.
We restate Theorem 4.7 as following.
Theorem C.23. 2-DRFWL(2) GNNs cannot graph-level count more than 7-cycles or more than 4-cliques.
Proof. The theorem is a direct corollary of Theorem 3.2. In the remark at the end of Appendix B.2, we have shown that no  $d$ -DRFWL(2) test can distinguish between two  $k$ -cycles and a single  $2k$ -cycle, as long as  $k \geqslant 3d + 1$ . For  $d = 2$ , we assert that no 2-DRFWL(2) test (thus no 2-DRFWL(2) GNN) can distinguish between two  $k$ -cycles and a  $2k$ -cycle, as long as  $k \geqslant 7$ . Therefore, 2-DRFWL(2) GNNs cannot graph-level count more than 7-cycles.
Moreover, Theorem 4.2 of [56] states that for any  $k \geqslant 2$ , there exists a pair of graphs with different numbers of  $(k + 1)$ -cliques that  $\mathrm{FWL}(k - 1)$  fails to distinguish between. Therefore, we assert that  $\mathrm{FWL}(2)$  cannot graph-level count more than 4-cliques. By Theorem 3.2, the 2-DRFWL(2) tests (thus 2-DRFWL(2) GNNs) are strictly less powerful than FWL(2) in terms of the ability to distinguish between non-isomorphic graphs. Therefore, 2-DRFWL(2) GNNs cannot graph-level count more than 4-cliques.
C.3 Proof of Theorem 4.8
Before proving the theorem, we state and prove a series of lemmas.
Lemma C.24. There exists a 3-DRFWL(2) test  $q$  such that for any graph  $G \in \mathcal{G}$  and for any 2-tuple  $(u, v) \in \mathcal{V}_G^2$  with  $1 \leqslant d(u, v) \leqslant 3$ ,  $q$  assigns
$$
W ^ {(T)} (u, v) = P _ {3} (u, v), \tag {109}
$$
Proof. If  $1 \leqslant d(u,v) \leqslant 2$ , the result follows from Lemma C.10 since 2-DRFWL(2) tests constitute a subset of 3-DRFWL(2) tests. If  $d(u,v) = 3$ , then equations (50)-(54) still hold (with the value of  $k$  changed to 3), giving rise to
$$
P _ {3} (u, v) = W _ {3} (u, v) = \frac {1}{2} \left(\sum_ {w \in \mathcal {N} _ {1} (u) \cap \mathcal {N} _ {2} (v)} P _ {2} (w, v) + \sum_ {w \in \mathcal {N} _ {2} (u) \cap \mathcal {N} _ {1} (v)} P _ {2} (u, w)\right), d (u, v) = 3. \tag {110}
$$
The RHS of (110) is obviously calculable by 3-DRFWL(2) tests. Therefore, the lemma holds.
Lemma C.25. There exists a 3-DRFWL(2) test  $q$  such that for any graph  $G \in \mathcal{G}$  and for any 2-tuple  $(u, v) \in \mathcal{V}_G^2$  with  $1 \leqslant d(u, v) \leqslant 3$ ,  $q$  assigns
$$
W ^ {(T)} (u, v) = P _ {4} (u, v), \tag {111}
$$
Proof. If  $1 \leqslant d(u,v) \leqslant 2$ , the result follows from Lemma C.12. If  $d(u,v) = 3$ , then equation (63) still holds, giving rise to
$$
P _ {4} (u, v) = P _ {2, 2} (u, v) = \sum_ {1 \leqslant i, j \leqslant 2} P _ {2, 2} ^ {i j} (u, v), \quad d (u, v) = 3. \tag {112}
$$
The definitions of  $P_{2,2}(u,v)$  and  $P_{2,2}^{ij}(u,v)$  are given in (57) and (65), respectively. In particular, we point out that
$$
P _ {2, 2} ^ {i j} (u, v) = \sum_ {w \in \mathcal {N} _ {i} (u) \cap \mathcal {N} _ {j} (v)} P _ {2} (u, w) P _ {2} (w, v)
$$
is calculable by 3-DRFWL(2) tests, for any  $1 \leqslant i, j \leqslant 2$  and for  $d(u,v) = 3$ . Therefore, the lemma holds.
Lemma C.26. There exists a 2-DRFWL(2) test  $q$  such that for any graph  $G \in \mathcal{G}$  and for any 2-tuple  $(u, v) \in \mathcal{V}_G^2$  with  $1 \leqslant d(u, v) \leqslant 2$ ,  $q$  assigns
$$
W ^ {(T _ {0})} (u, v) = T (u, v), \tag {113}
$$
for some integer  $T_0$ .
Proof. The lemma follows from
$$
T (u, v) = \sum_ {w \in \mathcal {N} _ {1} (u) \cap \mathcal {N} _ {1} (v)} P _ {2} (w, v) - 1 _ {d (u, v) = 1} P _ {2} (u, v), \tag {114}
$$
and Lemma C.7.
Lemma C.27. There exist two 2-DRFWL(2) tests  $q_1, q_2$  such that for any graph  $G \in \mathcal{G}$  and for any 2-tuple  $(u, v) \in \mathcal{V}_G^2$  with  $1 \leqslant d(u, v) \leqslant 2$ ,  $q_1, q_2$  assign
$$
W _ {1} ^ {(T _ {1})} (u, v) = C C _ {1} (u, v), \quad W _ {2} ^ {(T _ {2})} (u, v) = C C _ {2} (u, v), \tag {115}
$$
respectively, for some integers  $T_{1}$  and  $T_{2}$ .
Proof. The existence of  $q_{1}$  follows from the proof of Lemma C.17. To see why 2-DRFWL(2) tests can count  $CC_{2}(u,v)$ , notice that
$$
C C _ {2} (u, v) = \frac {1}{2} P _ {2} (u, v) \left(P _ {2} (u, v) - 1\right), \tag {116}
$$
and the result follows from Lemma C.7.
Due to the relations (32) and (33), we assert that 2-DRFWL(2) tests can also node-level count  $CC_{1}(u)$  and  $CC_{2}(u)$ .
Lemma C.28. There exist three 2-DRFWL(2) tests  $q_{1}, q_{2}$  and  $q_{3}$  such that for any graph  $G \in \mathcal{G}$  and for any node  $u \in \mathcal{V}_G$ ,  $q_{1}, q_{2}$  and  $q_{3}$  assign
$$
W _ {1} ^ {(T _ {1})} (u, u) = T R _ {1} (u), \quad W _ {2} ^ {(T _ {2})} (u, u) = T R _ {2} (u), \quad W _ {3} ^ {(T _ {3})} (u, u) = T R _ {3} (u), \tag {117}
$$
respectively, for some integers  $T_{1}, T_{2}$  and  $T_{3}$ .
Proof. From the proof of Lemma C.18 we see that 2-DRFWL(2) tests can count  $TR_{1}(u,v)$ . By (34), 2-DRFWL(2) tests can count  $TR_{1}(u)$  and  $TR_{2}(u)$ . We only need to prove that 2-DRFWL(2) tests can count  $TR_{3}(u)$ .
$$
\begin{array}{l} T R _ {3} (u) = \sum_ {v \in \mathcal {N} _ {1} (u) \cup \mathcal {N} _ {2} (u)} T R _ {2} (v, u) \\ = \sum_ {v \in \mathcal {N} _ {1} (u) \cup \mathcal {N} _ {2} (u)} \left(P _ {2} (u, v) - 1\right) T (u, v) - 2 C C _ {1} (u). \tag {118} \\ \end{array}
$$
Therefore, by Lemmas C.7, C.26 and C.27, the lemma is true.
Lemma C.29. There exists a 2-DRFWL(2) test  $q$  such that for any graph  $G \in \mathcal{G}$  and for any 2-tuple  $(u, v) \in \mathcal{V}_G^2$  with  $1 \leqslant d(u, v) \leqslant 2$ ,  $q$  assigns
$$
W ^ {(T)} (u, v) = C _ {2, 3} (u, v), \tag {119}
$$
$$
C _ {2, 3} (u, v) = P _ {2} (u, v) P _ {3} (u, v) - T (u, v) - T (v, u). \tag {120}
$$
Therefore, the lemma follows from Lemmas C.7, C.10 and C.26.
Now, we turn to proving Theorem 4.8. We restate the theorem as following.
Theorem C.30. For any  $d \geqslant 3$ ,  $d$ -DRFWL(2) GNNs can node-level count 3, 4, 5, 6, 7-cycles, but cannot graph-level count any longer cycles.
Proof. We first prove the negative result: for any  $d \geqslant 3$ ,  $d$ -DRFWL(2) GNNs cannot graph-level count  $k$ -cycles, with  $k \geqslant 8$ . This is because in terms of the ability to distinguish between non-isomorphic graphs,  $d$ -DRFWL(2) tests (and thus GNNs) are strictly less powerful than FWL(2), for any  $d$ , as shown in Theorem 3.2. Nevertheless, even the more powerful FWL(2) tests fail to graph-level count  $k$ -cycles with  $k \geqslant 8$ . [4]
Next, we will prove the positive result. Notice that the update rule of  $(d + 1)$ -DRFWL(2) GNNs always encompasses that of  $d$ -DRFWL(2) GNNs. Therefore, for any  $d \geqslant 3$ , the node-level cycle
counting power of  $d$ -DRFWL(2) GNNs is at least as strong as that of 2-DRFWL(2) GNNs. This implies that  $d$ -DRFWL(2) GNNs can node-level count 3, 4, 5, 6-cycles for any  $d \geqslant 3$ .
For the same reason, to prove that  $d$ -DRFWL(2) GNNs can node-level count 7-cycles for any  $d \geqslant 3$ , it suffices to prove that 3-DRFWL(2) GNNs can do so. By Lemma C.5, this reduces to proving the existence of a 3-DRFWL(2) test  $q$ , such that for any graph  $G \in \mathcal{G}$  and for any node  $u \in \mathcal{V}_G$ ,  $q$  assigns
$$
W ^ {(T)} (u, u) = C _ {7} (u), \tag {121}
$$
We try to calculate  $C_7(u)$  via
$$
C _ {7} (u) = \frac {1}{2} \sum_ {v: 1 \leqslant d (u, v) \leqslant 3} C _ {3, 4} (u, v). \tag {122}
$$
We assert that
$$
C _ {3, 4} (u, v) = P _ {3} (u, v) P _ {4} (u, v) - \# (\mathrm {a}) - \# (\mathrm {b}) - \dots - \# (1), \tag {123}
$$
where  $\# (\mathrm{a}),\# (\mathrm{b}),\ldots ,\# (\mathrm{l})$  refer to numbers of the substructures depicted in (a), (b), ..., (l) of Figure 7, respectively. Since  $P_{3}(u,v)$  and  $P_{4}(u,v)$  are calculable by 3-DRFWL(2) tests (by Lemmas C.24 and C.25), it now suffices to show that 3-DRFWL(2) tests can calculate the counts  $\# (\mathrm{a}),\# (\mathrm{b}),\ldots ,\# (\mathrm{l})$ , summed over all  $v$  with  $1\leqslant d(u,v)\leqslant 3$ .
(d)
(h)
(e)
(i)
Figure 7: The twelve substructures whose counts should be subtracted from  $P_{3}(u,v)P_{4}(u,v)$  to get  $C_{3,4}(u,v)$ .
(f)
(j)
For the rest of the proof, we express each of the counts  $\# (\mathrm{a}),\# (\mathrm{b}),\ldots ,\# (1)$  (after summing over  $\{v\in \mathcal{V}_G:1\leqslant d(u,v)\leqslant 3\}$ ) in terms of numbers already known calculable by 3-DRFWL(2) tests. Since the enumeration procedure is rather tedious, we directly provide the results below.
$$
\begin{array}{l} \sum_ {v: 1 \leqslant d (u, v) \leqslant 3} \# (\mathrm {a}) = \sum_ {v: 1 \leqslant d (u, v) \leqslant 2} \sum_ {w \in \mathcal {N} _ {1} (u) \cap \mathcal {N} _ {1} (v)} C _ {2, 3} (w, v) \\ + \sum_ {v: 1 \leqslant d (u, v) \leqslant 3} \sum_ {w \in \mathcal {N} _ {1} (u) \cap \mathcal {N} _ {2} (v)} C _ {2, 3} (w, v) \\ \end{array}
$$
$$
- 4 C _ {5} (u) - T R _ {2} (u), \tag {124}
$$
$$
\begin{array}{l} \sum_ {v: 1 \leqslant d (u, v) \leqslant 3} \# (\mathfrak {b}) = \sum_ {v: 1 \leqslant d (u, v) \leqslant 2} \sum_ {w \in \mathcal {N} _ {1} (u) \cap \mathcal {N} _ {1} (v)} P _ {2} (u, w) P _ {3} (w, v) \\ - \sum_ {v \in \mathcal {N} _ {1} (u)} \sum_ {w \in \mathcal {N} _ {1} (u) \cap \mathcal {N} _ {1} (v)} P _ {2} (u, w) \left(P _ {2} (u, w) - 1\right) \\ - \sum_ {v \in \mathcal {N} _ {1} (u)} \sum_ {w \in \mathcal {N} _ {1} (u) \cap \mathcal {N} _ {1} (v)} P _ {2} (w, v) \left(P _ {2} (w, v) - 1\right) \\ - C C _ {1} (u) - 2 C C _ {2} (u) - 4 T R _ {1} (u) - T R _ {2} (u), \tag {125} \\ \end{array}
$$
$$
\begin{array}{l} \sum_ {v: 1 \leqslant d (u, v) \leqslant 3} \# (\mathfrak {c}) = \sum_ {v: 1 \leqslant d (u, v) \leqslant 2} \sum_ {w \in \mathcal {N} _ {1} (u) \cap \mathcal {N} _ {1} (v)} P _ {2} (u, w) P _ {2} (w, v) (P _ {2} (w, v) - 1) \\ + \sum_ {v: 1 \leqslant d (u, v) \leqslant 3} \sum_ {w \in \mathcal {N} _ {1} (u) \cap \mathcal {N} _ {2} (v)} P _ {2} (u, w) P _ {2} (w, v) \left(P _ {2} (w, v) - 1\right) \\ - 2 T R _ {2} (u) - 4 C C _ {2} (u), \tag {126} \\ \end{array}
$$
$$
\begin{array}{l} \sum_ {v: 1 \leqslant d (u, v) \leqslant 3} \# (\mathrm {d}) = \sum_ {v: 1 \leqslant d (u, v) \leqslant 2} \sum_ {w \in \mathcal {N} _ {1} (u) \cap \mathcal {N} _ {1} (v)} P _ {2} (u, w) P _ {2} (w, v) (P _ {2} (u, w) - 1) \\ + \sum_ {v: 1 \leqslant d (u, v) \leqslant 3} \sum_ {w \in \mathcal {N} _ {2} (u) \cap \mathcal {N} _ {1} (v)} P _ {2} (u, w) P _ {2} (w, v) \left(P _ {2} (u, w) - 1\right) \\ - \sum_ {v \in \mathcal {N} _ {1} (u)} \sum_ {w \in \mathcal {N} _ {1} (u) \cap \mathcal {N} _ {1} (v)} P _ {2} (u, w) \left(P _ {2} (u, w) - 1\right) \\ - 4 C C _ {1} (u) - 4 T R _ {3} (u), \tag {127} \\ \end{array}
$$
$$
\begin{array}{l} \sum_ {v: 1 \leqslant d (u, v) \leqslant 3} \# (\mathfrak {e}) = \sum_ {v: 1 \leqslant d (u, v) \leqslant 2} \sum_ {w \in \mathcal {N} _ {1} (u) \cap \mathcal {N} _ {1} (v)} P _ {3} (u, w) P _ {2} (w, v) \\ - 2 \sum_ {v \in \mathcal {N} _ {1} (u)} \sum_ {w \in \mathcal {N} _ {1} (u) \cap \mathcal {N} _ {1} (v)} P _ {2} (w, v) \left(P _ {2} (w, v) - 1\right) \\ + 2 C C _ {1} (u) - 2 C C _ {2} (u) - T R _ {2} (u) - 2 T R _ {3} (u), \tag {128} \\ \end{array}
$$
$$
\begin{array}{l} \sum_ {v: 1 \leqslant d (u, v) \leqslant 3} \# (\mathrm {f}) = \sum_ {v: 1 \leqslant d (u, v) \leqslant 2} \sum_ {w \in \mathcal {N} _ {1} (u) \cap \mathcal {N} _ {1} (v)} C _ {2, 3} (u, w) \\ + \sum_ {v: 1 \leqslant d (u, v) \leqslant 3} \sum_ {w \in \mathcal {N} _ {2} (u) \cap \mathcal {N} _ {1} (v)} C _ {2, 3} (u, w) \\ - 4 C _ {5} (u) - T R _ {3} (u), \tag {129} \\ \end{array}
$$
$$
\begin{array}{l} \sum_ {v: 1 \leqslant d (u, v) \leqslant 3} \# (\mathfrak {g}) = \sum_ {v: 1 \leqslant d (u, v) \leqslant 2} \sum_ {w \in \mathcal {N} _ {1} (u) \cap \mathcal {N} _ {1} (v)} P _ {2} (u, w) P _ {2} (w, v) \\ + \sum_ {v: 1 \leqslant d (u, v) \leqslant 3} \sum_ {w \in \mathcal {N} _ {2} (u) \cap \mathcal {N} _ {1} (v)} P _ {2} (u, w) P _ {2} (w, v) \\ - 2 C C _ {2} (u) - C (\text {t a i l e d t r i a n g l e}, u, G), \tag {130} \\ \end{array}
$$
$$
\begin{array}{l} \sum_ {v: 1 \leqslant d (u, v) \leqslant 3} \# (\mathbf {h}) = \sum_ {v: 1 \leqslant d (u, v) \leqslant 2} \sum_ {w \in \mathcal {N} _ {1} (u) \cap \mathcal {N} _ {1} (v)} T (u, w) \\ + \sum_ {v: 1 \leqslant d (u, v) \leqslant 3} \sum_ {w \in \mathcal {N} _ {2} (u) \cap \mathcal {N} _ {1} (v)} T (u, w) \\ - 4 C (\text {t a i l e d t r i a n g l e}, u, G), \tag {131} \\ \end{array}
$$
$$
\sum_ {v: 1 \leqslant d (u, v) \leqslant 3} \# (\mathrm {i}) = T R _ {1} (u), \tag {132}
$$
$$
\sum_ {v: 1 \leqslant d (u, v) \leqslant 3} \# (\mathrm {j}) = \sum_ {v \in \mathcal {N} _ {1} (u)} \sum_ {w \in \mathcal {N} _ {1} (u) \cap \mathcal {N} _ {1} (v)} P _ {2} (w, v) \left(P _ {2} (w, v) - 1\right) - 4 C C _ {1} (u), \tag {133}
$$
$$
\begin{array}{l} \sum_ {v: 1 \leqslant d (u, v) \leqslant 3} \# (\mathrm {k}) = \sum_ {v: 1 \leqslant d (u, v) \leqslant 2} \sum_ {w \in \mathcal {N} _ {1} (u) \cap \mathcal {N} _ {1} (v)} P _ {2} (u, w) P _ {2} (w, v) \\ + \sum_ {v: 1 \leqslant d (u, v) \leqslant 3} \sum_ {w \in \mathcal {N} _ {1} (u) \cap \mathcal {N} _ {2} (v)} P _ {2} (u, w) P _ {2} (w, v) \\ - 3 \sum_ {v: 1 \leqslant d (u, v) \leqslant 2} T (v, u) - 4 C _ {3} (u) (d (u) - 2), \tag {134} \\ \end{array}
$$
$$
\sum_ {v: 1 \leqslant d (u, v) \leqslant 3} \# (1) = T R _ {3} (u). \tag {135}
$$
Combining the above results, we conclude that the theorem holds.
D Comparison between  $d$ -DRFWL(2) and localized FWL(2)
As mentioned in Section 5 of the main paper,  $d$ -DRFWL(2) can be seen as a sparse version of FWL(2). Another representative of this class of methods (adding sparsity to FWL(2)) is the localized FWL(2), proposed by Zhang et al. [58]. In [58], two instances of localized FWL(2) are provided, i.e., LFWL(2) and SLFWL(2). Different from  $d$ -DRFWL(2), both LFWL(2) and SLFWL(2) assign a color  $W(u,v)$  to every 2-tuple  $(u,v)\in \mathcal{V}_G^2$ , for any given graph  $G$ . Therefore, their space complexity is equal to that of FWL(2), namely  $O(n^{2})$ . The major difference between LFWL(2)/SLFWL(2) and FWL(2) is in their update rules. Similar to FWL(2), both LFWL(2) and SLFWL(2) update  $W(u,v)$  using a multiset of the form  $\{(W(w,v),W(u,w))\}$ . However, for LFWL(2), we restrict  $w$  to be in  $\mathcal{N}(v)$ ; for SLFWL(2), we restrict  $w$  to be in  $\mathcal{N}(u)\cup \mathcal{N}(v)$ . Since restricting the range of  $w$  reduces the multiset size from  $O(n)$  (as in FWL(2)) to  $O(\deg)$ , the time complexity of LFWL(2) and SLFWL(2) is  $O(n^{2}\deg)$ , which is usually much lower than the  $O(n^{3})$  time complexity of FWL(2).