Manuscript Offprint
arXiv:2610.07503Two-Sample Testing for Random Graphs without Vertex Correspondence
Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.
Abstract
Two populations of graphs often have to be compared without any correspondence between their vertices, for instance when networks come from different communities, or when a graph generative model is evaluated against held-out graphs. We study how many graphs such an unaligned two-sample test needs, and which graph statistics can detect which differences. For an Erdős–Rényi null and a planted two-block difference that leaves every expected degree unchanged, we show that graphs per group are necessary and sufficient when the per-graph signal-to-noise ratio is . Signed triangle counts attain this rate, and the lower bound holds for every graph size. With aligned vertices graphs suffice, so misalignment costs a factor of order . When the triangle signal cancels, the rate becomes and 4-cycles are needed. Statistics built from trees have exactly the same expectation under both hypotheses, and tests based on finitely many of them have asymptotically no power. In the graphon limit, this class includes degree distributions and message-passing graph neural network features. For a non-constant null, a generic difference is visible at first order, and a simple motif test attains the aligned order of sample size, suggesting that misalignment is costly mainly for differences that are invisible at low orders. We also give an exactly valid test for one or two graphs per group, at a cost in power. In our simulations, the fitted exponents are close to the predicted ones ( against for unaligned tests and against for aligned ones), and degree-based and random-GNN evaluation metrics stay at their level in a setting where signed triangles need about 65 graphs.
1 Introduction
A two-sample test for networks decides whether two samples of graphs come from the same distribution. Often the vertices of different graphs do not correspond, as with friendship networks of different schools, protein networks of different species, or molecules. The same is true when a graph generative model is evaluated, since its samples are compared with held-out graphs through degree distributions, clustering coefficients, subgraph counts or random graph-neural-network embeddings [You et al., 2018, O'Bray et al., 2022, Thompson et al., 2022, Krimmel et al., 2025]. Without a correspondence, a test can only use quantities that do not depend on how each graph is labelled.
With aligned vertices, the sample complexity of two-sample testing for inhomogeneous random graphs is well understood [Ghoshdastidar et al., 2020, Chatterjee et al., 2023]. Without alignment, many tests have been proposed [Maugis et al., 2020, Bravo-Hermsdorff et al., 2023, Shao et al., 2026, Tang et al., 2017, Sabanayagam et al., 2021], but two basic questions remain open: how many graphs are needed, and which statistics can detect which differences? In practice, an evaluation metric that is insensitive to a class of failures reports a good model however many samples are drawn.
In this paper, we study both questions for graphon models, in which every graph has its own latent vertex positions. Our results suggest that both answers depend on the lowest order at which a
Preprint.
difference becomes visible to label-invariant statistics, and this order can be high for differences that are easy to detect with aligned vertices.
• Sample complexity (Theorem 1). For an Erdős–Rényi null and a planted two-block difference that preserves every expected degree, with per-graph signal-to-noise ratio , we prove that graphs per group are necessary and sufficient and that signed triangles are optimal, with a lower bound that holds for every graph size. With aligned vertices graphs suffice, so misalignment costs a factor of order . When the triangle signal cancels, the rate becomes and 4-cycles are needed (Proposition 1).
• Tree statistics (Theorem 2). If the null is regular and the difference preserves degrees, every tree density is exactly unchanged, and tests using finitely many tree statistics have asymptotic power equal to their level. Since degree statistics, colour refinement and message-passing graph neural networks are determined by tree densities on graphons [Grebík and Rocha, 2022, Böker, 2023, Böker et al., 2023], they cannot detect such differences either.
• Order of visibility (Theorem 3). For a non-constant null, a difference is generically visible at first order, and a motif test that does not know the null needs only order 1/t graphs, the aligned rate of Theorem 1. So the factor in Theorem 1 reflects first-order invisibility.
• Few graphs and experiments. We give an exact permutation test for one graph per group (Proposition 2), and our simulations confirm the predicted exponents. Degree- and GNN-based metrics miss degree-preserving changes both in simulations and on protein graphs, where degree-corrected signed cycles reach power 1/2 with at most six graphs.
The second moment behind our lower bound for one graph is due to Mossel et al. [2015] and Banerjee [2018], Ghoshdastidar et al. [2017] use the same planted partition as a hard instance for one graph per group, and the sharp aligned threshold is known for sparse multilayer block models [Chatterjee et al., 2022]. The population bounds, their comparison with alignment, the distributional invariance of tree statistics and the first-order analysis are new.
Unaligned two-sample testing. We observe and , all independent, and test against . A test maps the 2m graphs to , and its risk against a pair of hypotheses is the sum of its type I and type II errors. The samples are unaligned: every graph carries its own latent positions, so a vertex label in one graph says nothing about a vertex label in another. For a graphon model this is automatic, because the law of is invariant under relabelling. Averaging any test over independent uniform relabellings of each graph therefore preserves both of its errors, and we may restrict attention to (possibly randomized) tests that are invariant under relabelling within each graph. Invariant polynomials of bounded degree are exactly linear combinations of subgraph counts [Carpentier et al., 2025, Lemma 3.2]. In the aligned version of the problem, all graphs share one vertex labelling and one set of latent positions.
The planted-partition difference. Our main example has an Erdős–Rényi null and the alternative in which a vector with independent uniform entries is drawn and, given , edges are independent with
This is the graphon with and . Since , every vertex has the same expected degree under both hypotheses. We write


Figure 1: Left: number of graphs per group at which each test reaches power 1/2 at level 0.05, for the planted partition (1) with n = 300 and p = 1/2. Unaligned tests (signed triangles with known p, excess triangle density with unknown p) follow the slope -3 of Theorem 1. Aligned tests (cross-graph statistic Q, top eigenvalue of the averaged adjacency matrix) follow the slope -1. Below the black curve, the information bound of Theorem 1(i) rules out power 1/2 for every test. Right: the ratio of unaligned to aligned sample sizes, with a reference line proportional to .
and call the per-graph signal-to-noise ratio. In the notation and of the community detection literature, . The value is the threshold below which a single graph from cannot be distinguished from [Mossel et al., 2015, Banerjee, 2018]. Unaligned samples draw an independent for each graph. Aligned samples use one for all graphs of the first group.
Order of visibility. For graphons W and and a motif F, expanding the product over the edges of F gives
where each term integrates over the edges in and over the remaining edges of . The terms with sum to , where is the density of with the endpoints of fixed at and the edge removed. They are closely related to the two-point conditional kernels of Chatterjee et al. [2026]. We say that is visible at order (relative to ) if some motif has a non-vanishing term with and none has one with . When is constant and has zero degree function, integrating out a vertex of degree one in gives zero, so only edge sets in which every vertex has degree at least two survive. The smallest such sets are triangles and 4-cycles, with densities and , and hence is visible at order 3 if and at order 4 otherwise. For (1), and the order is 3.
3 Sample complexity under an Erdős–Rényi null
Write . Let for , and let be its finite- version, where . Let .
Theorem 1 (Unaligned and aligned sample complexity). Let , , and .
(i) Unaligned, lower bound. For and every ,
Hence a two-sample test with type I error at most and type II error at most exists only if . For this requires .
(ii) Unaligned, upper bound. Let . The test that rejects when
has size at most under . Its power is at least whenever
where is explicit (Section A.2).
(iii) Aligned. Suppose the graphs of the first sample share one . With the root of , no test has errors if , where . The cross-graph statistic gives errors against the null once , where is explicit.
Parts (ii) and (iii) use the null edge density . For the triangle test, the pooled edge density of all 2m graphs can replace with no asymptotic loss when (Proposition 3), and conditioning on the total number of edges gives an exactly valid Monte Carlo version.
Corollary 1. Fix with . Let and be the smallest numbers of graphs per group for which some test has errors in the unaligned and in the aligned problem. There are constants , depending only on , such that for and
Misalignment multiplies the number of graphs needed by a factor of order .
Proof idea. With and , two independent partitions give with . Averaging over removes every monomial with a vertex of odd degree. By Veblen's theorem each remaining edge set is an edge-disjoint union of cycles, and the sum is at most . Edges and 2-stars drop out, and the triangles contribute the leading . With aligned graphs each edge contributes , whose even part leaves a second-order term of about , so aligned tests succeed at order .
Sign cancellation. In the following model, triangles carry no signal. Let be independent with uniform entries, and
The difference has eigenvalues , so and .
Proposition 1 (Sign cancellation). Under (4), with :
(i) , so triangles carry no signal. The two-sample triangle test has asymptotic power for fixed , and .
(ii) For , a test with errors requires .
(iii) The signed 4-cycle count has mean and null variance . Its per-graph squared signal-to-noise ratio tends to , and the two-sample 4-cycle test has errors once and .
The lower bound rests on , where is the cyclomatic number, so odd cycles drop out of the second moment. It also explains why signed quadrilaterals can beat signed triangles [Jin et al., 2021], and why the statistic of Chatterjee et al. [2026] is slower than triangles when but cannot be cancelled.
4 Tree statistics and degree-preserving differences
The expansion (3) already suggests that statistics built from trees cannot detect degree-preserving differences, since every tree has a leaf and integrating the leaf of an H-edge returns the degree function of H, which is zero. The next theorem makes this exact and extends it to distributions.
Theorem 2 (Invariance of tree statistics). (i) Let be a graphon with , and let be bounded and symmetric with for almost every and . Then for every finite forest . Consequently is the same under and for every .
(ii) In the planted-partition model (1), fix , , and finitely many trees . For each tree, let be the signed count over the copies of in , divided by its null standard deviation. As , the vector converges to under both and . Hence every test that depends on the graphs only through these counts has asymptotic power equal to its asymptotic size. The signed triangle z-test has asymptotic power .
We prove part (i) by removing leaves one at a time, and part (ii) by a conditional central limit theorem given . A signed tree count has mean zero under because every leaf has odd degree, and its covariances change only through pairs of trees whose union contains a cycle, which contribute a relative change of order (Section A.4). Interestingly, the statement also holds above the one-graph threshold ( ), where a single graph already reveals through its spectrum. Under , every vertex degree is exactly Binomial( ), since the signs , , are independent and uniform, and the edge count has exactly the null mean and variance.
Consequences for invariant learned features. Colour refinement (the 1-dimensional Weisfeiler–Leman algorithm) and message-passing graph neural networks cannot distinguish graphons with equal tree homomorphism densities, since on graphons their expressive power is exactly that of tree densities [Grebik and Rocha, 2022, Böker, 2023, Böker et al., 2023], and the same holds for degree statistics. Theorem 2 therefore applies to many two-sample statistics in common use, including maximum mean discrepancies between degree distributions, Weisfeiler–Leman subtree kernels [Shervashidze et al., 2011], and features from randomly initialized or trained message-passing networks [Thompson et al., 2022]. Against a regular null their population targets coincide for every degree-preserving difference, and for finitely many tree statistics Theorem 2(ii) gives zero asymptotic power at any fixed m, whereas clustering coefficients, orbit counts and spectra involve cycles and are not affected. One consequence concerns the evaluation of graph generative models [O'Bray et al., 2022, Thompson et al., 2022]. Against a regular null, a model that reproduces the degree structure of its training graphs but gets their community or cycle structure wrong cannot be detected by metrics built from degrees or message passing, as Section 7 shows. Weisfeiler–Leman tests of dimension at least two do not share this limitation, since they determine homomorphism counts of all graphs of treewidth two, cycles included [Dell et al., 2018, Morris et al., 2019].
The limitation needs both a degree-preserving difference and a regular null. For a planted subgraph on top of , which always increases degrees, signed star counts are optimal among constant-degree tests [Yu et al., 2025]. Under an irregular null, a vertex at position has degree Binomial( , ) under both hypotheses, so the expected degree histogram is the same. Trees with an internal edge acquire a first-order term, equal to for the path with three edges and non-zero for generic , and colour refinement separates the graphons (Section 5).
5 Non-constant nulls and first-order visibility
The rate in Theorem 1 comes from a special feature of the Erdős–Rényi null. There every kernel in (3) is constant, so a difference with zero degree function has for every motif, and it cannot be seen before order three. For a non-constant null the first-order term is generically non-zero, and a simple motif test that does not need to know already detects the difference.
Theorem 3 (First-order visibility). Let be a fixed graph with vertices and edges, and let be a graphon. Let be the difference between the two sample averages of .
(i) for , for every graphon and .
(ii) If , then , with .
(iii) The test that rejects when has size at most under every graphon null . Its power against , is at least whenever .
Part (i) is the Efron–Stein inequality applied to the independent blocks , where with i.i.d. uniform , since changing one block moves by at most , and part (iii) is Chebyshev's inequality under both hypotheses. No constant depends on .
Corollary 2 (Order of visibility). Let , and suppose the first-order coefficient is non-zero. If , the test of Theorem 3(iii) has power at least as soon as . With , the unaligned sample size is therefore , the order of an aligned test under every null (Proposition 4) and at a constant null (Theorem 1(iii)). If is constant and has zero degree function, then for every and the rate becomes or worse (Theorem 1 and Proposition 1).
The corollary is only an upper bound, since for a non-constant null we do not prove matching lower bounds for either aligned or unaligned tests (Section 9). Degeneracy of the null can improve the constant further. If W is F-regular, the variance in (i) drops from order to order [Bhattacharya et al., 2023, Chatterjee et al., 2026], and the test gains a factor of n.
Degree-corrected block models have finite rank. For a degree-preserving difference that is orthogonal to their eigenfunctions, every path density is unchanged and every cycle density moves by exactly , as under the Erdős–Rényi null (Proposition 5), so we expect the rate to persist. Other degree-preserving differences are generically visible at first order.
6 Testing with one to three graphs per group
The rates above matter most for small m, which is where standard calibrations fail. Permuting whole graphs is exact, but for a two-sided statistic its smallest p-value is , which equals 1, 1/3 and 1/10 for m = 1, 2, 3. Normal approximations estimate a variance from only degrees of freedom, and the network jackknife is conservative in expectation [Lin et al., 2020]. However, graphon models have a simple structure that makes exact tests possible with a single graph per group.
Proposition 2 (Exact vertex-split permutation test). Partition [n] into fixed blocks . If , the induced subgraphs are independent, and . If both samples come from and the blocks have equal size, the 2mB values of any statistic computed on the induced subgraphs are therefore independent and identically distributed. A permutation test over their group labels has level at most for every m and B, and a two-sided version can reject as soon as , for instance when and .
This uses only motifs inside a block. For signed triangles under an Erdős–Rényi null, a block of size has per-graph signal-to-noise ratio , so the squared signal-to-noise ratio of a graph drops from about to . With and its power in our experiments is only 0.06 for a first-order visible difference and 0.02 under the Erdős–Rényi null (Table 1 in Section B.3), so it mainly guarantees validity. For a mixture of graphons the blocks are only conditionally independent, so the test is not exact.
7 Experiments
Apart from one study of protein graphs, the experiments use simulated graphs, so the ground truth is known. Every number below is read from result files produced by the scripts in the arXiv ancillary files, which use only NumPy and SciPy. For each test we report , the smallest number of graphs per group at which the power reaches 0.5 at level 0.05, interpolated on a geometric grid of m. Settings, replicate counts and run times are in Section B.
Sample sizes with and without alignment. Figure 1 uses the planted partition with , and . The fitted slopes of on are for signed

scale c of the difference
scale c of the difference
scale c of the difference
Figure 2: The same degree-preserving difference added to three nulls ( ): Erdős–Rényi, a regular two-block model (SBM2) and an irregular smooth graphon (SMOOTH). The plots show against the scale for the unaligned excess-triangle test and for two aligned tests, with thin curves for the prediction from the exact shift. Under the constant null the sample size of the unaligned test grows like , while under the non-constant nulls it tracks the aligned tests, whose sample size grows like . Open markers extend the grid to small , and arrows mark censored values.
triangles (theory -3), for the aligned spectral test (theory -1), for Q, whose signal-to-noise ratio grows like at small m, and and for the unaligned-to-aligned ratio (theory -2). At signed triangles need 1241 graphs per group, against 1215 predicted by the normal approximation. The aligned tests need 11.3 and 4.53, a ratio of 110 to 274, and the ratio is 10.4 to 31.6 at .
With a pooled edge density, an unknown costs nothing, whereas the per-graph excess triangle density needs 4.0 times more graphs because it keeps the degree-variance fluctuation. The information bound lies a factor of 12.2 to 37.2 below the triangle test, a gap due to the constant in Le Cam's inequality, the second sample and longer cycles, relevant near (Remark 6). A sparse panel (, average degree 15) gives the same exponents, and (Section B.2).
Sign cancellation. Under the rank-two model (4), the triangle test never exceeds a rejection rate of 0.063 for any and any . Signed 4-cycles detect the difference with slope (theory -4), from 1392 graphs at to 17.4 at (Section B.2).
Order of visibility under non-constant nulls. Figure 2 adds one degree-preserving difference to three nulls. Its first-order coefficient is zero under the Erdős–Rényi null and and under SBM2 and SMOOTH. At the unaligned excess-triangle test needs 3991 graphs under the Erdős–Rényi null, against 11.1 under SBM2 and 83.7 under SMOOTH (360 and 48 times fewer). The aligned spectral test needs about 10 graphs under each null.
Under the constant null the unaligned slope in is (theory ), whereas under the non-constant nulls it approaches the first-order value as , with local slopes and on (s.e. at most 0.10 and 0.09). Over the slopes are steeper, and , because higher-order terms of are still comparable to there. Every uncensored agrees with the prediction within Monte Carlo error.
Graph evaluation metrics. We test descriptors used to evaluate graph generative models [You et al., 2018, O'Bray et al., 2022, Thompson et al., 2022], namely the degree histogram, the clustering histogram, six graphlet counts, the Laplacian spectrum and a randomly initialized graph isomorphism network (GIN) [Xu et al., 2019], each compared by a Gaussian-kernel MMD [Gretton et al., 2012], together with signed triangles (Figure 3).
degree histogram clustering histogram Laplacian spectrum signed triangles, theory random GIN graphlet counts signed triangles

Figure 3: Power of two-sample tests on descriptors used to evaluate graph generative models. Descriptors are compared by a Gaussian-kernel MMD calibrated by permutation, and signed triangles by a permutation test on the mean difference (n = 200, p = 0.1, 200 replicates per point, horizontal line at level 0.05). Left and middle: planted partition (1) against . Right: planted-partition graphs against the same graphs after degree-preserving double-edge swaps. Tree-based descriptors (dashed) stay at the level, and the dotted curve is the normal-theory power of signed triangles.
Against the planted partition, the degree histogram and the random GIN reject at rates between 0.030 and 0.075 for every m up to 256, at both t = 0.9 and t = 1.5, so they stay at the level, as Theorem 2 predicts. Both metrics have power 1.00 with m = 16 against a degree-heterogeneous graphon of the same edge density, where signed triangles have power 0.05.
Signed triangles reach power 0.5 at for and for , against 64.2 and 13.9 predicted by the normal approximation with the moments of Theorem 1(ii). The clustering histogram needs 196.8 and 40.3 graphs, and the graphlet vector needs > 256 because edge-density fluctuations, which move all counts together, dominate its kernel distance.
The right panel of Figure 3 models a generator that reproduces degrees exactly but destroys cycle structure, with group 2 consisting of planted-partition graphs with t = 2 after degree-preserving double-edge swaps. Signed triangles detect the change with m = 7.4 graphs, clustering with 19.3 and the spectrum with 61.2, but the degree and GIN metrics never exceed a rejection rate of 0.090.
Irregular nulls and protein graphs. Under two irregular nulls, SMOOTH and a rank-one graphon, the random GIN detects a degree-preserving difference that is correlated with the degree profile, with power 0.80 and 1.00 at m = 64, through the first-order term of the 3-edge path (Section B.5, where the signal is above the one-graph threshold). It stays at the level, with rejection rates between 0.015 and 0.095 up to m = 256 (Monte Carlo s.e. 0.015), when the difference is orthogonal to the eigenfunctions of the null, which leaves every path density unchanged (Proposition 5). On protein graphs from two generative-model benchmarks (Section B.6), rewiring 5% of the edges of each graph by degree-preserving swaps removes about a quarter of its triangles. The degree histogram and the random GIN never exceed a rejection rate of 0.075 for , whereas degree-corrected signed triangles reach power 0.83 with m = 4 on D&D and signed 4-cycles need on ENZYMES. We chose their normalization in a pilot on D&D (Section B.6).
Calibration with few graphs. With one to three graphs per group (Table 1 in Section B.3), whole-graph permutation never rejects, the Welch normal approximation reaches size 0.21 at m = 2, and only the vertex-split test (Proposition 2) has a finite-sample guarantee at m = 1. Conservative variance estimates keep power for first-order visible differences (SBM2 null). Under the Erdős–Rényi null, where the difference is third-order visible, the best method valid for all three nulls reaches power 0.15, so with few graphs only first-order differences appear testable without strong assumptions.
8 Related work
With aligned vertices, minimax rates for two-sample testing of inhomogeneous random graphs are known [Ghoshdastidar et al., 2020, Chatterjee et al., 2023]. Without alignment, tests compare network statistics of one graph per group [Ghoshdastidar et al., 2017], latent positions [Tang et al., 2017], subgraph counts and cumulants [Maugis et al., 2020, Bravo-Hermsdorff et al., 2023, Shao et al., 2026], or estimated block models and graphons [Nguen et al., 2025, Sabanayagam et al., 2021, Qi et al., 2024], and our excess triangle statistic is the of Gao and Lafferty [2017]. Subgraph counts are the classical moments of network models [Bickel et al., 2011], and populations of unlabeled networks have been studied through graph distances [Kolaczyk et al., 2020, Lunagómez et al., 2021].
Misalignment has been studied for aligned tests with shuffled labels [Saxena and Lyzinski, 2025] and for changepoints [Chen et al., 2026]. The choice of cycle order for one graph is studied for signed polygons, latent geometry and planted subgraphs [Jin et al., 2021, Bubeck et al., 2016, Bangachev and Bresler, 2024, Yu et al., 2025], and low-degree analyses of invariant tests treat one graph [Kunisky et al., 2024, Carpentier et al., 2025, Rush et al., 2026, Skeja et al., 2026], whereas our lower bounds are information-theoretic and use independence across graphs. Section C discusses more work.
9 Discussion and limitations
Our results suggest that the number of unaligned graphs needed is set by the lowest order at which the difference is visible to invariant statistics. A motif test attains the aligned order of sample size for differences visible at first order, whereas degree-preserving differences from a constant null, first visible through cycles, cost a power of the signal-to-noise ratio and are invisible to tree statistics.
A recommendation for evaluation pipelines. Metrics built from degrees or message passing should be complemented by cycle statistics. A cheap choice is the signed triangle and 4-cycle counts of , the degree-corrected centring of Jin et al. [2021], divided by the number of 2-paths, which depends only on the degrees. They need one matrix product per graph, and permuting whole graphs makes the test exact. In our experiments they detected every degree-preserving difference under irregular nulls and the unrestricted rewiring of the protein graphs (Sections B.5 and B.6).
Limitations. The sharp rates of Section 3 are for an Erdős–Rényi null and two explicit alternatives. For non-constant nulls we prove upper bounds only, since matching lower bounds would need a second-moment method for nulls that are mixtures over latent positions, which we leave open. Theorem 2 needs a regular null, and part (ii) covers finitely many tree statistics in the dense regime, so message-passing architectures at finite n remain open. Partially aligned samples, such as networks registered to a common atlas, and tests that first estimate the partition of each graph when t > 1 are outside our analysis. Apart from the protein graphs, whose alternative is a synthetic rewiring, our experiments are simulations, and the exact small-m test gives up motifs that cross blocks.
Broader impact. This methodological work mainly bears on the evaluation of generative models of networks, where metrics that ignore cycles can report a good fit for a model that is wrong in ways they cannot detect. We do not foresee negative societal consequences.
References
Taha Ameen and Bruce Hajek. Sharp detection threshold for correlation among multiple unlabeled Gaussian networks. arXiv preprint arXiv:2504.16279, 2025.
Debapratim Banerjee. Contiguity and non-reconstruction results for planted partition models: the dense case. Electronic Journal of Probability, 23:Paper No. 18, 1–28, 2018. doi: 10.1214/17-EJP128.
Debapratim Banerjee and Zongming Ma. Optimal hypothesis testing for stochastic block models with growing degrees. arXiv preprint arXiv:1705.05305, 2017.
Kiril Bangachev and Guy Bresler. Detection of geometry in random geometric graphs: Suboptimality of triangles and cluster expansion. In Proceedings of the Thirty Seventh Conference on Learning Theory, volume 247 of Proceedings of Machine Learning Research, pages 427–497, 2024.
Patrice Bertail, Dimitris N. Politis, and Joseph P. Romano. On subsampling estimators with unknown rate of convergence. Journal of the American Statistical Association, 94(446):569–579, 1999. doi: 10.2307/2670177.
Bhaswar B. Bhattacharya, Anirban Chatterjee, and Svante Janson. Fluctuations of subgraph counts in graphon based random graphs. Combinatorics, Probability and Computing, 32:428–464, 2023. doi: 10.1017/S0963548322000335.
Peter J. Bickel, Aiyou Chen, and Elizaveta Levina. The method of moments and degree distributions for network models. The Annals of Statistics, 39(5):2280–2301, 2011. doi: 10.1214/11-AOS904.
Jan Böker. Weisfeiler–Leman indistinguishability of graphons. The Electronic Journal of Combinatorics, 30(4), 2023. doi: 10.37236/10973.
Jan Böker, Ron Levie, Ningyuan Huang, Soledad Villar, and Christopher Morris. Fine-grained expressivity of graph neural networks. In Advances in Neural Information Processing Systems, volume 36, pages 46658–46700, 2023.
Karsten M. Borgwardt, Cheng Soon Ong, Stefan Schönauer, S. V. N. Vishwanathan, Alex J. Smola, and Hans-Peter Kriegel. Protein function prediction via graph kernels. Bioinformatics, 21(Suppl. 1):i47–i56, 2005. doi:10.1093/bioinformatics/bti1007.
Stéphane Boucheron, Gábor Lugosi, and Pascal Massart. Concentration Inequalities: A Nonasymptotic Theory of Independence. Oxford University Press, 2013.
Gecia Bravo-Hermsdorff, Lee M. Gunderson, Pierre-André Maugis, and Carey E. Priebe. Quantifying network similarity using graph cumulants. Journal of Machine Learning Research, 24(187):1–27, 2023.
Sébastien Bubeck, Jian Ding, Ronen Eldan, and Miklós Z. Rácz. Testing for high-dimensional geometry in random graphs. Random Structures & Algorithms, 49:503–532, 2016. doi: 10.1002/rsa.20633.
Alexandra Carpentier, Simone Maria Giancola, Christophe Giraud, and Nicolas Verzelen. Low-degree lower bounds via almost orthonormal bases. arXiv preprint arXiv:2509.09353, 2025.
Anirban Chatterjee, Sagnik Nandy, and Ritwik Sadhu. Detecting planted partition in sparse multi-layer networks. arXiv preprint arXiv:2209.07554, 2022.
Anirban Chatterjee, Soham Dan, and Bhaswar B. Bhattacharya. Higher-order graphon theory: Fluctuations, degeneracies and inference. The Annals of Statistics, 54(4):2136–2163, 2026. doi: 10.1214/26-AOS2644.
Sayak Chatterjee, Dibyendu Saha, Soham Dan, and Bhaswar B. Bhattacharya. Two-sample tests for inhomogeneous random graphs in norm: Optimality and asymptotics. In Proceedings of the 26th International Conference on Artificial Intelligence and Statistics, volume 206 of Proceedings of Machine Learning Research, pages 6903–6911, 2023.
Li Chen, Jie Zhou, and Lizhen Lin. Hypothesis testing for populations of networks. arXiv preprint arXiv:1911.03783, 2019.
Tianyi Chen, Mohammad Sharifi Kiasari, Sijing Yu, Youngser Park, Avanti Athreya, Vince Lyzinski, Carey E. Priebe, and Zachary Lubberts. Vertex misalignment and changepoint localization in network time series. arXiv preprint arXiv:2604.20072, 2026.
Holger Dell, Martin Grohe, and Gaurav Rattan. Lovász meets Weisfeiler and Leman. In 45th International Colloquium on Automata, Languages, and Programming (ICALP 2018), 2018. arXiv:1802.08876.
Jian Ding, Hang Du, and Zhangsong Li. Low-degree hardness of detection for correlated Erdős–Rényi graphs. The Annals of Statistics, 53(5), 2025. doi: 10.1214/25-AOS2517.
Paul D. Dobson and Andrew J. Doig. Distinguishing enzyme structures from non-enzymes without alignments. Journal of Molecular Biology, 330(4):771–783, 2003. doi: 10.1016/S0022-2836(03)00628-4.
Bradley Efron and Charles Stein. The jackknife estimate of variance. The Annals of Statistics, 9(3):586–596, 1981. doi: 10.1214/aos/1176345462.
Dor Elimelech and Wasim Huleihel. Detecting arbitrary planted subgraphs in random graphs. arXiv preprint arXiv:2503.19069, 2025.
Chao Gao and John Lafferty. Testing network structure using relations between small subgraph probabilities. arXiv preprint arXiv:1704.06742, 2017.
Debarghya Ghoshdastidar, Maurilio Gutzeit, Alexandra Carpentier, and Ulrike von Luxburg. Two-sample tests for large random graphs using network statistics. In Proceedings of the 2017 Conference on Learning Theory, volume 65 of Proceedings of Machine Learning Research, pages 954–977, 2017.
Debarghya Ghoshdastidar, Maurilio Gutzeit, Alexandra Carpentier, and Ulrike von Luxburg. Two-sample hypothesis testing for inhomogeneous random graphs. The Annals of Statistics, 48(4):2208–2229, 2020. doi:10.1214/19-AOS1884.
Jan Grebík and Israel Rocha. Fractional isomorphism of graphons. Combinatorica, 42(3):365–404, 2022. doi:10.1007/s00493-021-4336-9.
Alden Green and Cosma Rohilla Shalizi. Bootstrapping exchangeable random graphs. Electronic Journal of Statistics, 16(1):1058–1095, 2022. doi: 10.1214/21-EJS1896.
Arthur Gretton, Karsten M. Borgwardt, Malte J. Rasch, Bernhard Schölkopf, and Alexander Smola. A kernel two-sample test. Journal of Machine Learning Research, 13:723–773, 2012.
Jan Hladký, Christos Pelekis, and Matas Šileikis. A limit theorem for small cliques in inhomogeneous random graphs. Journal of Graph Theory, 97:578–599, 2021. doi: 10.1002/jgt.22673.
Svante Janson. Random regular graphs: asymptotic distributions and contiguity. Combinatorics, Probability and Computing, 4(4):369–405, 1995.
Jiashun Jin, Zheng Tracy Ke, and Shengming Luo. Optimal adaptivity of signed-polygon statistics for network testing. The Annals of Statistics, 49(6):3408–3433, 2021. doi: 10.1214/21-AOS2089.
Jaehyeong Jo, Seul Lee, and Sung Ju Hwang. Score-based generative modeling of graphs via the system of stochastic differential equations. In Proceedings of the 39th International Conference on Machine Learning, volume 162 of Proceedings of Machine Learning Research, pages 10362–10383, 2022.
Gursharn Kaur and Adrian Röllin. Higher-order fluctuations in dense random graph models. Electronic Journal of Probability, 26, 2021. doi: 10.1214/21-EJP708.
Matthias Kirchler, Shahryar Khorasani, Marius Kloft, and Christoph Lippert. Two-sample testing using deep learning. In Proceedings of the 23rd International Conference on Artificial Intelligence and Statistics, 2020. arXiv:1910.06239.
Eric D. Kolaczyk, Lizhen Lin, Steven Rosenberg, Jackson Walters, and Jie Xu. Averages of unlabeled networks: Geometric characterization and asymptotic behavior. The Annals of Statistics, 48(1):514–538, 2020. doi:10.1214/19-AOS1820.
Markus Krimmel, Philip Hartout, Karsten Borgwardt, and Dexiong Chen. PolyGraph discrepancy: a classifier-based metric for graph generation. arXiv preprint arXiv:2510.06122, 2025.
Jonas M. Kübler, Vincent Stimper, Simon Buchholz, Krikamol Muandet, and Bernhard Schölkopf. AutoML two-sample test. In Advances in Neural Information Processing Systems, volume 35, pages 15929–15941, 2022.
Dmitriy Kunisky, Alexander S. Wein, and Afonso S. Bandeira. Notes on computational hardness of hypothesis testing: Predictions using the low-degree likelihood ratio. arXiv preprint arXiv:1907.11636, 2019.
Dmitriy Kunisky, Cristopher Moore, and Alexander S. Wein. Tensor cumulants for statistical inference on invariant distributions. In 2024 IEEE 65th Annual Symposium on Foundations of Computer Science (FOCS), pages 1007–1026, 2024.
Renjie Liao, Yujia Li, Yang Song, Shenlong Wang, William L. Hamilton, David Duvenaud, Raquel Urtasun, and Richard Zemel. Efficient graph generation with graph recurrent attention networks. In Advances in Neural Information Processing Systems, volume 32, 2019.
Qiaohui Lin, Robert Lunde, and Purnamrita Sarkar. On the theoretical properties of the network jackknife. In Proceedings of the 37th International Conference on Machine Learning, volume 119 of Proceedings of Machine Learning Research, pages 6105–6115, 2020.
Feng Liu, Wenkai Xu, Jie Lu, Guangquan Zhang, Arthur Gretton, and Danica J. Sutherland. Learning deep kernels for non-parametric two-sample tests. In Proceedings of the 37th International Conference on Machine Learning, volume 119 of Proceedings of Machine Learning Research, pages 6316–6326, 2020.
Feng Liu, Wenkai Xu, Jie Lu, and Danica J. Sutherland. Meta two-sample testing: Learning kernels for testing with limited data. In Advances in Neural Information Processing Systems, volume 34, pages 5848–5860, 2021.
László Lovász. Large Networks and Graph Limits, volume 60 of Colloquium Publications. American Mathematical Society, 2012.
Simón Lunagómez, Sofia C. Olhede, and Patrick J. Wolfe. Modeling network populations via graph distances. Journal of the American Statistical Association, 116(536):2023–2040, 2021. doi: 10.1080/01621459.2020.1763803.
Cheng Mao, Yihong Wu, Jiaming Xu, and Sophie H. Yu. Testing network correlation efficiently via counting trees. The Annals of Statistics, 52(6), 2024. doi: 10.1214/23-AOS2261.
P.-A. G. Maugis, S. C. Olhede, C. E. Priebe, and P. J. Wolfe. Testing for equivalence of network distribution using subgraph counts. Journal of Computational and Graphical Statistics, 29(3):455–465, 2020. doi:10.1080/10618600.2020.1736085.
Christopher Morris, Martin Ritzert, Matthias Fey, William L. Hamilton, Jan Eric Lenssen, Gaurav Rattan, and Martin Grohe. Weisfeiler and Leman go neural: Higher-order graph neural networks. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 33, pages 4602–4609, 2019. doi: 10.1609/aaai.v33i01.33014602.
Christopher Morris, Nils M. Kriege, Franka Bause, Kristian Kersting, Petra Mutzel, and Marion Neumann. TUDataset: A collection of benchmark datasets for learning with graphs. In ICML 2020 Workshop on Graph Representation Learning and Beyond, 2020. arXiv:2007.08663.
Elchanan Mossel, Joe Neeman, and Allan Sly. Reconstruction and estimation in the planted partition model. Probability Theory and Related Fields, 162:431–461, 2015. doi: 10.1007/s00440-014-0576-6.
Chung Kyong Nguen, Oscar Hernan Madrid Padilla, and Arash A. Amini. Network two-sample test for block models. In Advances in Neural Information Processing Systems, volume 38, pages 184600–184644, 2025.
Leslie O'Bray, Max Horn, Bastian Rieck, and Karsten Borgwardt. Evaluation metrics for graph generative models: Problems, pitfalls, and practical solutions. In International Conference on Learning Representations, 2022.
Mingyu Qi, Chen-Wei Hua, Tianxi Li, and Wen Zhou. Multivariate inference of network moments by subsampling. arXiv preprint arXiv:2409.01599, 2024.
Cynthia Rush, Fiona Skerman, Alexander S. Wein, and Dana Yang. Is it easier to count communities than find them? Random Structures & Algorithms, 68(4), 2026. doi: 10.1002/rsa.70071.
Mahalakshmi Sabanayagam, Leena Chennuru Vankadara, and Debarghya Ghoshdastidar. Graphon based clustering and testing of networks: Algorithms and theory. arXiv preprint arXiv:2110.02722, 2021.
Ayushi Saxena and Vince Lyzinski. Lost in the shuffle: Testing power in the presence of errorful network vertex labels. Computational Statistics & Data Analysis, 204:108091, 2025. doi: 10.1016/j.csda.2024.108091.
Meijia Shao, Dong Xia, Yuan Zhang, Qiong Wu, and Shuo Chen. Higher-order accurate two-sample network inference and network hashing. Journal of the American Statistical Association, 121:373–388, 2026. doi:10.1080/01621459.2025.2520459.
Nino Shervashidze, Pascal Schweitzer, Erik Jan van Leeuwen, Kurt Mehlhorn, and Karsten M. Borgwardt. Weisfeiler–Lehman graph kernels. Journal of Machine Learning Research, 12:2539–2561, 2011.
Anda Skeja, Daniel Gutiérrez Espinoza, Fiona Skerman, and Alexander S. Wein. Sharp low-degree thresholds for planted-vs-planted testing. arXiv preprint arXiv:2606.05266, 2026.
Minh Tang, Avanti Athreya, Daniel L. Sussman, Vince Lyzinski, and Carey E. Priebe. A nonparametric two-sample hypothesis testing problem for random graphs. Bernoulli, 23(3):1599–1630, 2017. doi: 10.3150/15-BEJ789.
Rylee Thompson, Boris Knyazev, Elahe Ghalebi, Jungtaek Kim, and Graham W. Taylor. On evaluation metrics for graph generative models. In International Conference on Learning Representations, 2022.
Yihong Wu, Jiaming Xu, and Sophie H. Yu. Testing correlation of unlabeled random graphs. The Annals of Applied Probability, 33, 2023. doi: 10.1214/22-AAP1786.
Keyulu Xu, Weihua Hu, Jure Leskovec, and Stefanie Jegelka. How powerful are graph neural networks? In International Conference on Learning Representations, 2019.
Jiaxuan You, Rex Ying, Xiang Ren, William L. Hamilton, and Jure Leskovec. GraphRNN: Generating realistic graphs with deep auto-regressive models. In Proceedings of the 35th International Conference on Machine Learning, volume 80 of Proceedings of Machine Learning Research, pages 5708–5717, 2018.
Xifan Yu, Ilias Zadik, and Peiyuan Zhang. Counting stars is constant-degree optimal for detecting any planted subgraph. Mathematical Statistics and Learning, 8(1):105–164, 2025. doi: 10.4171/MSL/51.
Yuan Zhang and Dong Xia. Edgeworth expansions for network moments. The Annals of Statistics, 50(2):726–753, 2022.
A Proofs
This appendix proves the results of Sections 3 to 6 in the order of the main text. Twelve numerical checks, numbered (i)–(xii), test identities and bounds below by exact enumeration on small graphs or by simulation. Their scripts and outputs are part of the code released with the paper.
Conventions. We write , let be the set of unordered pairs , and put . A graph on is identified with its adjacency vector .
For , is the set of endpoints of edges in , the degree of in , , the number of connected components of the graph and its cyclomatic number. We call even if , and denotes the set of even , including . For a finite graph , is its set of cycles, viewed as edge sets.
For we write , with . For and we write , so that
For a graph without isolated vertices, is the set of copies of , that is, of the with , and . Throughout, , , and . The null is . The planted partition law draws uniformly from and then, given , independent , where . Tests may be randomized, so a test takes values in .
A.1 Preliminaries
Lemma A.1 (Tensorization, two-sample reduction and Le Cam). Let be probability measures on finite sets with , .
(a)
(b)
(c) For every test , , and .
(d) Let be a set of pairs of laws containing and a set containing . Then every test of , where , are independent, satisfies
Proof. (a) The likelihood ratio of the products is with , and under the factors are independent, so . (b) . (c) because . By Cauchy–Schwarz, . (d) The left side is at least , which by (c) and (b) is at least . Finally apply (c) and (a).
Remark 1. Lemma A.1(d) shows that a two-sample test is never better than a one-sample test that knows the null law. The lower bounds below therefore hold for the one-sample problem, for tests that know , and for tests that use the vertex labels.
Lemma A.2 (Per-edge second moment). Let be a random element with law and with . Let be the law of when, given , the are independent
where is an independent copy of .
Proof. Let and . If , then , and if , then . Multiplying over edges gives and, averaging over , . Under the are independent with and , so and the product formula follows. The last identity follows from by Fubini's theorem, since all quantities are finite sums.
Lemma A.3 (Even-subgraph expansion). Let be a finite graph, uniform on and real. Then
In particular .
Proof. Expanding the product, , and by (5).
Lemma A.4 (Veblen-type bound). Let be a finite graph and . Then
For and this reads with .
Proof. Every even edge set is a union of pairwise edge-disjoint cycles (Veblen's theorem). To see this, let be even. The graph has minimum degree at least two and so contains a cycle , and is again even, so induction on applies. Fix for each even one such decomposition . The cycles in are distinct and pairwise edge-disjoint, so , and is injective because . Since all terms are non-negative, , and . In there are cycles of length (sequences of distinct vertices up to the rotations and 2 reflections), which gives .
Lemma A.5 (The function ). For and , .
Proof. The bound gives , the closed form follows from , and the last inequality from .
Lemma A.6 (Curie–Weiss form and asymptotic exactness of the bound). For let and with uniform on . Then
If and , then .
Proof. For , . Hence and , so Lemma A.3 gives the identity. As , , so , and . Finally , because in law, , and the family is uniformly integrable. For the last point take . Then eventually, and Hoeffding's inequality gives with [Mossel et al., 2015, arXiv version, Lemma 5.5].
Lemma A.7 (Moments of signed sums under latent-variable models). In the setting of Lemma A.2, write , and . Given , the are independent, centred, and . Let be a finite set of edge sets and . For put . Then
and
Proof. , and collecting terms by gives . Given , by independence and centring, which gives the conditional mean and variance. The last identity is the law of total variance.
A.2 Theorem 1: sample complexity under a constant null
Theorem (Restatement of Theorem 1). Let , , , , , for .
(i) with . For , and as . Every test of against with graphs per group has ; errors require , and for , .
(ii) The moments of are as in Lemma A.8. The test , , , has size under and type II error under whenever , where and is as in Lemma A.8.
(iii)
(iv) Let , and . For and ,
Proof of (i). We compute exactly, bound it by a product over cycles, and tensorize over the graphs. By Lemma A.2 with and , and with . For independent uniform , is uniform on , so Lemma A.3 gives , and Lemma A.4 with gives . Lemma A.1(a) gives . Lemma A.5 gives the comparison with , and Lemma A.6 (with , ) the limit . The error bound is Lemma A.1(d) with . If a test has errors , then , which rearranges to , that is, .
Remark 2 (Exact evaluation). Lemma A.6 gives exactly as a sum of terms. For the E11 settings ( , ) the exact , and agree to within 10% (numerical check (ii)). The lower-bound curve with , is 101.6, 17.4, 4.58 at , 0.5, 0.7.
Lemma A.8 (Signed triangles and signed cherries under the planted partition). Let and . Then , , for every , and
For the signed cherry count (sum over paths ):
, and .
Proof. We expand and in the orthogonal basis of Lemma A.7 and add up the squared coefficients.
Signed triangles. Apply Lemma A.7 with , and the set of triangles. Since and , we have . By (5), for every triangle , so is non-random. The non-empty contained in a triangle are of three kinds:
• the triangle itself, with ;
• a path , contained only in the triangle , with and ;
• a single edge ij, contained in the triangles , with and .
By (5), , which equals for a triangle, for a path and for an edge. There are triangles, paths and edges, which gives the formula for . Setting gives and . For the bound we use , , and , which holds because . Finally, .
Signed cherries. For take the set of paths of length two. Now for the path , so , with mean 0 and second moment . The non-empty are the paths themselves, with and , and single edges . An edge lies in the paths and (), so with . As is independent of , and , we get . Summing over the paths and the edges gives the claim, and gives .
Proof of (ii). Write and . Under , and , so Chebyshev's inequality gives . Under , and . If , then . Dividing by and using and (Lemma A.8), this holds when .
Remark 3 (Size of the constants). equals the term of exactly, so the signed triangle count captures the leading term of the one-graph divergence. With a normal approximation (justified in Theorem 2(ii), Remark 9) the one-sided two-sample test has power , which reaches at for . A cruder bound, , is also valid, since it exceeds the exact value by at least .
Proposition 3 (Unknown p: the pooled plug-in statistic). Let be the edge density of the pooled sample of 2m graphs, , and .
(a) Under every null (any law of random graphs), has the same law as ; in particular .
(b) identically, hence , where and are the between-group differences of and .
(c) Under and under : , , and with . Consequently, for every , with probability at least ,
In particular, if and is bounded, , and the test with has asymptotic size at most and the power guarantee of Theorem 1(ii) up to .
Proof. (a) Under the graphs are i.i.d. Exchanging the two groups leaves unchanged and maps to .
(b) For a triangle with centred entries , . Summing over triangles, every path of length two lies in exactly one triangle and every edge in triangles. The terms cancel between the groups because both have graphs.
(c) We bound the random quantities , and of (b) and then compare the error with the threshold .
Moments. By Theorem 2(i), applied to the planted partition as with and of zero degree, the edge count of one graph has mean and variance under both and . The 2m graphs are independent, which gives the moments of and . Since , is the sum of the 2m second moments.
Concentration. Chebyshev's inequality with thresholds , , for , , shows that all three bounds hold with probability at least . On this event , which is the display.
Order of the error. By Lemma A.8, , so the first term is when is bounded, and the second is . Since , we get in probability.
Size and power. When , in probability because , so satisfies . Fix . On the event we have . Hence under , by Chebyshev, and letting gives asymptotic size at most . The power statement follows in the same way from the proof of (ii), with replaced by .
Remark 4 (Exact validity for the composite Erdős–Rényi null). Under with unknown, the total number of edges of the 2m graphs is sufficient, and conditionally on
the 2m adjacency vectors are uniform over the configurations. A Monte Carlo test that compares with its law under uniform redistribution of the edges is therefore exactly valid for every . We do not use this test elsewhere.
Lemma A.9 (Aligned second moment). Let be the law of when one is drawn and the are i.i.d. planted-partition graphs given . Then, with , as in Theorem 1(iii),
Moreover and .
Proof. The likelihood ratio is with as in Lemma A.2, so by independence of the under and Lemma A.2, with uniform. For , , and Lemma A.3 with gives the identity.
For the bounds, , and because is the number of sets of pairwise disjoint pairs in , which is at most . Hence . With , , so .
Lemma A.10 (Moments of the aligned statistic). For , , , , and with as in Lemma A.8. In particular with .
Proof. Given , with and the independent, centred, with variance . Then . The three kinds of terms are conditionally uncorrelated and different pairs are independent, so and . Taking expectations with and gives the moments, and gives the null moments. For the ratio, and give .
Proof of (iii). The identity is Lemma A.9. By Lemma A.4 with (so ) and we get the bound, where . If then and , so (Lemma A.5, g increasing) and , which by Lemma A.1(c), (d) rules out errors . The bound follows from .
For the test, Lemma A.10 and Chebyshev's inequality give size , and type II error once . Dividing by gives .
Remark 5 (Sharp aligned threshold). By Lemma A.6 applied with ( ) and , for fixed and with one gets , which is finite exactly when . This is consistent with the sharp aligned threshold of Chatterjee et al. [2022, Theorem 2.1]. Their setting has layers sharing one planted bipartition, in the sparse regime with fixed and average degree > 1. They prove contiguity if and asymptotic singularity if > 1, where . Identical layers and no covariates give and . We cite this result for the sharp constant and do not reprove it. In the dense regime we only claim the bounds of Theorem 1(iii).
Proof of (iv). Let and . Then , so , and .
Unaligned lower bound. By (i), .
Unaligned upper bound. Since , and , we have , and for . So the condition of (ii) holds for every , and .
Aligned lower bound. By (iii), no test exists when , so .
Aligned upper bound. Let . Then , , and because by the choice of . Hence , so (iii) gives a test with errors and .
Ratio. Since , . In the other direction, .
Remark 6 (Asymptotically sharp constants). The constants in (iv) come from Chebyshev and -to-TV conversions and are loose. For fixed , dense and fixed , sharp constants follow from the likelihood-ratio limit of Banerjee [2018, arXiv version, Theorem 2.2 with Proposition 3.4, display (3.2)]. Under , in law, with independent . The hypotheses of that theorem are and with , which is our dense regime with and . Thus under , and by Le Cam's third lemma the most powerful level- test of against has asymptotic power . The one-sample signed-triangle test with known has asymptotic power (Remark 9). Since , this test is asymptotically optimal including the constant as . The two-sample version, which does not use the knowledge of , pays a factor 2 in .
A.3 Proposition 1: sign cancellation
Throughout this subsection are independent and uniform on , , , , and is the law of when the are independent given . Put , and . Every conditional edge variance lies in .
Proposition (Restatement of Proposition 1).
(i) For every , .
(ii) ; , , and under , with as in Lemma A.12. With , the test , , has size under and type II error under whenever .
(iii) . If this is at most , where ; the middle quantity tends to . Errors require .
(iv) Under the triangle test of Theorem 1(ii) has power at most , with as in Lemma A.12; for fixed p, m, t the statistic converges in law to under both hypotheses, so the triangle z-test has asymptotic power exactly .
Lemma A.11 (Sign-cancellation identity). For every , . In particular for every triangle, for every 4-cycle and whenever has a vertex of odd degree.
Proof. Expanding the product and using independence of and and (5),
Since , both indicators can equal one only if is even, so unless is even.
If is even, is even iff is, and , where is the set of even subsets of . Under symmetric difference is the cycle space of the graph , a vector space over of dimension , and is a group homomorphism into because . The sum of a homomorphism over a finite group is the group order if it is trivial and 0 otherwise (if , substituting changes the sign of the sum). is trivial iff every even subset of has even size iff every cycle of has even length (cycles span ) iff is bipartite. In that case is even because , and .
Lemma A.12 (Moments under the rank-two model). Under :
(a) , and ; hence with .
(b) , where is the number of 4-cycles whose vertices alternate between and ; , , , and with
Proof. We apply Lemma A.7 with and , and bound the variance class by class. Three facts are used repeatedly:
• , so ;
• pointwise.
(a) For a triangle , and because two of the three values coincide. Hence . The non-empty are triangles , paths and edges . For an edge,
using and Lemma A.11 for the 4-cycle . With triangles, paths, edges and we get the upper bound. The lower bound keeps only the triangle terms and uses . Dividing by gives , since .
(b) Mean. For a 4-cycle , and , with value 16 iff alternates around . So . Each 4-cycle alternates with probability 2/16, which gives and .
The variance Var K. The indicators of two 4-cycles sharing at most one vertex x are conditionally independent given , with conditional means 1/8 not depending on , hence uncorrelated. A 4-cycle meets at most 4-cycles in two or more vertices, and each covariance is at most 1/8. So Var .
Coefficients. The non-empty R contained in a 4-cycle fall into five classes.
(1) The 4-cycles themselves, with .
(2) Paths with 3 edges. Here is the closing edge and , and there are of them.
(3) Paths with 2 edges, contained in the cycles with . Here and, as in (a), . There are of them.
(4) Pairs of disjoint edges , contained in the cycles and . Here and . There are of them.
(5) Single edges ij, contained in the cycles ij kl with ordered, distinct and outside . Here .
For class (5) we expand over pairs .
• Equal pairs give , with terms.
• Pairs with form a 6-cycle and give , with terms.
• Pairs with (or ) give , where is the 4-cycle . This equals , with terms.
• Pairs with (or ) consist of six distinct edges containing the triangle (or ), so they give 0 by Lemma A.11.
• The swapped pair , gives , where is the 4-cycle . It vanishes because forces alternation on , hence and .
Altogether
Conclusion. Summing the five contributions with , adding , and dividing by gives
using and . The final inequality uses , and .
Remark 7. We verified the exact values of all coefficients in this proof by enumeration over for , and compared the resulting variance bounds with exact variances for (numerical check (vi), parts (c) and (d)).
Lemma A.13 (Second moment under the rank-two model). , and the bounds of Proposition 1(iii) hold.
Proof. By Lemma A.2 with , , where and is built from an independent copy . Expanding, , and Lemma A.11 gives the first formula.
For the bound, let and . The map is a bijection of , so are independent and uniform. Since , with . Conditioning on and applying Lemmas A.3 and A.4 to the graph with ,
Cycle structure. Classify vertices by the type , with class sizes , , , . Then iff the types are opposite, so is the disjoint union of the complete bipartite graphs and . All their cycles have even length , and has cycles of length .
The bound. With (the events are independent with probability ), and . Hence , which is finite because . This is the middle bound. Since for , , which gives .
The limit and the sample size. As , almost surely along the obvious coupling, so , and dominated convergence (the integrand is at most ) gives the limit. Finally , and Lemma A.1(d) gives the sample-size bound exactly as in Theorem 1(i).
Proof of Proposition 1. (i) is Lemma A.11, and (iii) is Lemma A.13.
(ii) The moments are Lemma A.12(b) and, for , the orthogonality of distinct 4-cycles under . The test analysis is that of Theorem 1(ii) with , mean shift and .
(iv) Under , by Lemma A.12(a), so by Chebyshev's inequality , and when and . The central limit statement is proved in Remark 9.
A.4 Theorem 2: invariance of tree statistics
For a graph with at least one edge let be its set of copies in , , and define the normalized signed count .
Theorem (Restatement of Theorem 2). (i) Let W be a graphon with for a.e. x, and H a bounded symmetric measurable function with a.e. and . Then for every finite forest T. Consequently, for all , ; under both and every vertex degree has law and the edge count has mean and variance .
(ii) Fix , , , pairwise non-isomorphic trees with at least one edge, and let (admissible for ). Under and under , in law. Moreover, under , . Hence for independent graphs the vector converges to under and , every test with Lebesgue-null has the same limiting rejection probability under both, and the one-sided signed-triangle -test has asymptotic power .
Lemma A.14 (Leaf removal). If is a graphon with a.e., then for every finite forest .
Proof. Induction on . If , . Otherwise has a leaf with unique neighbour . By Fubini, integrating first, for a.e. , so , where is the forest obtained by deleting and its edge.
Proof of (i). is a graphon and a.e., so Lemma A.14 applies to and to . For and an injective , the latent values are i.i.d. uniform, so and . For the degree of vertex , condition on . Then the pairs are i.i.d. with , so independently of . For the edge count, , if share one vertex , the path with two edges, is a tree), and are independent if .
Remark 8. (a) The planted partition is with and , , so (i) contains the identities and , which numerical check (ix) confirms by enumeration. The first difference in the moments of the edge count appears in the third central moment, , and for the rank-two model only in the fourth, .
(b) Only injective densities are invariant. Homomorphism densities of the sampled graph include non-injective maps whose images may contain cycles (for example, a path with three edges whose endpoints coincide), and joint laws of several degrees are not invariant. For irregular W, trees may detect a zero-degree H at first order. For the path with three edges the first-order coefficient is , which is for the SMOOTH null and the of the experiments (numerical check (xi)).
(c) Message-passing networks and colour refinement on graphons are characterized by tree homomorphism densities [Böker et al., 2023, Böker, 2023]. By (i), the graphons W and have identical tree homomorphism densities, so by that characterization no message-passing network and no colour-refinement statistic separates them at the level of graphons.
Lemma A.15 (Method of moments for signed subgraph chaoses). Let be pairwise non-isomorphic connected graphs with at least one edge, , , and let . Let be independent with , and . Put
For every there is depending only on , and (not on or on the law of ) such that for ,
where for ( for even and for odd ).
Proof. We expand the mixed moment as a sum over tuples of copies, show that only tuples whose copies coincide in pairs contribute at leading order, and count the remaining tuples. Let , list the factors as with shapes , and let . Then , the sum over tuples with . For a tuple let and . By independence , which vanishes unless for all (call such tuples admissible). For admissible tuples , using (so ).
Claim. For an admissible tuple, , with equality iff the tuple is paired: splits into pairs with and the vertex sets of different pairs are disjoint. To see this, let . As has no isolated vertex, some lies in , and as , lies in some , . So every vertex of lies in at least two of the , whence . In case of equality every vertex lies in exactly two copies. Take and , and let be the other copy containing . Every edge lies in a second copy, which contains and hence is . So , and the two copies containing are again , . By connectedness of , , and symmetrically . So , their common vertex set meets no other copy, and because the are non-isomorphic. The converse is clear.
Counting. A tuple is determined by injective maps from the vertex sets of the into . Grouping these maps by the partition of the disjoint union of the vertex sets that they induce, we see that the number of tuples with is at most with depending only on the and . Since for , the normalizing factor is at most .
Admissible tuples that are not paired have and contribute at most in total. For a perfect matching of pairing indices of equal shape, the paired tuples with pairing contribute each (the pairs have disjoint edge sets), and different give disjoint sets of tuples. Dropping the disjointness constraint between different pairs adds tuples with at most vertices, which after normalization contribute . Without the constraint the sum over tuples factorizes and equals . After normalization the paired contribution is therefore , and because a set of size has perfect matchings.
Lemma A.16 (Reduction to the chaos under the planted partition). Let , , and . For a graph with at least one edge let .
(a) Let be a tree with at least one edge and , and let . Then (with ).
(b) For a tree with edges and vertices, and .
(c) For the cycle ( ), and .
Proof. Part (a) is a combinatorial fact about the subforests of a tree. Parts (b) and (c) bound the terms of the expansion in Lemma A.7 that lie outside the chaos , and each of these terms carries a factor of order , by (a) for trees and because for cycles.
(a) If there is nothing to prove. If , contains the leaves of , of which there are at least two. If , let be a connected component of the forest (non-empty since ). meets : otherwise would be vertex-disjoint from and from the other components, contradicting connectedness of . meets in at most one vertex: two common vertices would be joined by a path in and an edge-disjoint path in the connected , creating a cycle in the tree . is a tree with at least one edge, so it has at least two leaves, one of which, , is not in . Since has degree one in , .
(b) By Lemma A.7 with , over edge sets strictly contained in some copy ( included), and these terms are conditionally orthogonal to each other and to (no proper subset of a copy is itself a copy). Here by (5). In particular has mean 0 because . By (5), , and . Fix and . Every admissible contains the vertices of (as ), so there are at most of them. Hence
With , and (valid for forests, including ), the power of is by (a). There are at most sets , which gives (b).
(c) We repeat the computation with . Now is non-random, because every vertex of a cycle has even degree, and this gives the mean. For , is a union of paths and the power of is since .
Proof of (ii). We prove a conditional central limit theorem given by the method of moments, transfer it from to , and then add the triangle.
Conditional moments. Condition on . The are independent, centred, bounded by one, with variances . With as in Lemma A.15, deterministically, because with fixed. Lemma A.15, whose constant does not depend on the , gives uniformly in , hence for all .
Limit law. These are the mixed moments of , which is determined by its moments, so in law. By Lemma A.16(b) and Slutsky's lemma the same holds for . The case is the null .
Adding the triangle. Adding (connected and containing a cycle, hence non-isomorphic to the ) and using Lemma A.16(c) with gives the joint statement.
Several graphs and tests. The 2m graphs are independent, so the vectors of the individual graphs converge jointly to independent limits. The portmanteau theorem gives the statement on tests. For the triangle test, under and under .
Remark 9 (The triangle statistic under the alternatives). The proof shows under , which justifies the normal calibration used in Remark 6 and in the experiments. Under the rank-two model the same argument applies conditionally on , because , the non-chaos terms have relative variance at most (Lemma A.12(a)), and the conditional variances satisfy . Hence under , which completes the proof of Proposition 1(iv).
Remark 10 (Scope of (ii)). (a) The result holds for every fixed , including , where a single graph suffices to detect the planted partition by cycle statistics, so tree statistics fail to detect the difference even above the one-graph threshold. It requires . For fixed the edge count has the non-Gaussian limit under , although its mean and variance are exactly those of the null.
(b) The proof uses fixed only through the constant of Lemma A.15, which grows like . Extending (ii) to sparse graphs (, ) requires a sharper count of non-paired tuples, as in Banerjee [2018, arXiv version, Proposition 4.1] for signed cycles. We do not claim it.
(c) Part (ii) concerns fixed finite families of signed tree counts. Unsigned tree counts, degree moments and colour-refinement histograms are polynomials in signed forest counts, and in the dense regime their centred and normalized versions are dominated by the edge count. We expect, but do not prove, that every fixed finite family of such statistics also has the same limit under and , and that the same holds for fixed-depth message-passing embeddings with Lipschitz readouts.
A.5 Theorem 3: non-constant nulls and first-order visibility
A graphon is a symmetric measurable . We realize with independent uniform variables and , setting . For a graph with vertices, , the sum over injective . For an edge (with a fixed orientation ) the edge-rooted kernel is
where for . For symmetric , does not depend on the orientation. For , for each edge. This kernel differs from the symmetrized two-point conditional kernel of Chatterjee et al. [2026], which includes the factor of the rooted edge.
Theorem (Restatement of Theorem 3). Let have vertices and edges.
(i) For every graphon and : and .
(ii) For every graphon W and symmetric measurable H with : with .
(iii) With and , the test has size at most under for every graphon , and type II error at most under , whenever , in particular whenever ; here . (The threshold is also valid; it requires .)
(iv) Let be symmetric and bounded with for , and . For , , and the test of (iii) has errors at most against as soon as . With , . If is constant and , then for every .
Lemma A.17 (Efron–Stein with vertex blocks). For every graphon W, graph F with v vertices and : and .
Proof. For injective the variables are i.i.d. uniform, so . For the variance, let . The are independent and is a function of . Moreover, depends only on , hence only on and . So when varies and the other blocks are fixed, only the terms of with change. There are such and each term lies in . Hence, as a function of alone, ranges in an interval of length at most and its conditional variance given is at most . The Efron–Stein inequality [Efron and Stein, 1981, Boucheron et al., 2013] gives .
Lemma A.18 (First-order expansion). For every graphon W and symmetric measurable H with , with .
Proof. Note since . Expanding the product over edges, . The term is , and the term is by Fubini. For pick two edges in and bound all other factors by one in absolute value: the term is at most . If share a vertex this is by Cauchy–Schwarz, and if they are disjoint it is . There are sets with .
Proof of Theorem 3. (i) and (ii) are Lemmas A.17 and A.18.
(iii) The 2m graphs are independent, so by (i), for every of graphon type. Under , and Chebyshev's inequality gives . Under the alternative by (i). If , then . The sufficient condition follows from . The variant with threshold is analogous.
(iv) By (ii), under the stated restriction on , so , and (iii) applies once . If is constant, and .
Remark 11 (The E12 nulls). For , with . For the difference of the experiments ( on , across, on , zero degree function), the zero degree of kills every term of that depends on one variable only, and one finds the following values.
• for .
• For SBM2, and .
• For SMOOTH, and .
For the remainder of Lemma A.18 is well within its bound (numerical check (xi)). At the second-order terms are of the same size as for these nulls.
Remark 12 (Regular nulls and calibration). The bound in (i) holds for every and is tight in order when is -irregular. If is -regular in the sense of Bhattacharya et al. [2023], the count of fluctuates on the smaller scale (compared with in the irregular case), so that , and its limit law may contain weighted components. Chatterjee et al. [2026] give the joint limits and a multiplier bootstrap that is consistent in both regimes. The -agnostic threshold of (iii) is then conservative by a factor of order , and a two-sample test calibrated at the scale would need only . We do not prove the two-sample version.
Remark 13 (Scope of (iv)). (iv) is an upper bound. A first-order visible difference is detected by an unaligned motif test with graphs. This is the order reached by an aligned test under the same null (Proposition 4 below) and the order of the aligned sample size at a constant null (Theorem 1(iii), where ), compared with for the first-order invisible difference of Theorem 1. We do not prove a matching lower bound for non-constant nulls (the null is then itself a mixture over latent positions, and the second-moment method of Section A.2 does not apply directly), nor an aligned lower bound for non-constant nulls. The oracle that knows all latent positions gives only .
Proposition 4 (An aligned test under every null). Let be a graphon and symmetric with , and suppose that all graphs share the latent positions . Given , the edges of are independent , and the edges of are independent , . Let , , and .
(i) If , then and for every , so the test with has size at most under every null. The test that compares with its law under independent random signs of is exact.
(ii) If and , the test of (i) has power at least .
In particular an aligned test needs graphs per group under every null.
Proof. Given , the variables are independent over edges and over . Fix an edge and write with and centred of variance . Then
and the last two terms are uncorrelated. Hence and . Summing over the edges, with ,
(i) For these are the stated moments, and Chebyshev's inequality gives the size. Given and , and are exchangeable, so the law of does not change when the are multiplied by independent random signs. This makes the sign-change test exact.
(ii) The variable has mean . Two edges without a common vertex give independent terms. For two edges with one common vertex the covariance is at most , where , and because . Hence , and Chebyshev's inequality gives
On the complementary event, let . The second condition gives , so . Since , the first condition gives . Therefore
and Chebyshev's inequality gives . Adding the probability of the exceptional event proves (ii).
Proposition 5 (Differences orthogonal to a null of finite rank). Let be a graphon of finite rank, and let be bounded and symmetric with , zero degree function and for almost every and . Then for every path , and for every cycle , . In particular the first-order coefficient vanishes for every path and every cycle , and every cycle density moves by exactly , as under a constant null.
Proof. Let and be the integral operators of and on . The range of is spanned by , so , and because both kernels are symmetric. The zero degree function gives .
For a path with edges, . In a product of the factors and that contains , the rightmost acts either on 1 or on the range of , so the product annihilates 1. Hence .
For a cycle, . A product of factors that contains both operators has, after a cyclic rotation that does not change its trace, a factor or , so its trace is zero, and .
The hypotheses also hold for , , so does not depend on and . Both derivatives vanish at .
Remark 14 (Degree-corrected nulls). A degree-corrected block model with blocks has rank at most , and its eigenfunctions lie in the span of the functions . For a degree-preserving difference orthogonal to these functions, Proposition 5 shows that the first-order test of Theorem 3 has no signal for any path or cycle, and that the triangle density moves by exactly , as in Theorem 1. We therefore expect the rate to persist for such differences. The lower bound would need the second-moment method for a null that is a mixture over latent positions, which we have not carried out. A degree-preserving difference that is not orthogonal to the eigenfunctions is generically visible at first order, through the path with three edges and through the triangle, and Corollary 2 applies. Trees in which two adjacent vertices both have degree at least three can keep a first-order term in the orthogonal case. For the double star with two leaves at each centre and it equals , which is at most for the nulls of E15 (Section B.5).
A.6 Proposition 2: exact calibration by vertex splitting
Proposition (Restatement of Proposition 2). Let be fixed, pairwise disjoint, of equal size .
(i) Under with a fixed graphon , the induced subgraphs (relabelled increasingly by ) are independent with law .
(ii) Let , , be the induced subgraphs of the 2m graphs, the mB indices from group one, and a statistic satisfying for all permutations of (e.g. a difference of group means of a graph functional). With , for all under every null ; the randomized p-value is exactly uniform. Since , a rejection at level requires .
(iii) Under the planted partition, has mean and null variance ; its squared signal-to-noise ratio is .
(iv) If the common null law is a mixture of graphon laws (a graphon drawn at random for each graph), the need not be exchangeable and the test in (ii) need not be valid.
Lemma A.19 (Induced subgraphs on disjoint vertex sets). Statement (i) holds.
Proof. is a function of and . These collections are disjoint for different , hence independent. The law of is that of by definition.
Lemma A.20 (Validity of permutation p-values). Let be exchangeable, , , and as in (ii). Then satisfies . With independent of , the randomized p-value is uniform on .
Proof. Let be a uniform -subset of independent of and a permutation with . By exchangeability has the law of , so has the law of , because permutes the -subsets.
Given , write . For any finite list of reals, the number of indices with is at most (if has the smallest value among them, all of them satisfy ). Hence .
For the same substitution shows that, given , has the law of with uniform, which is uniform on (the ranks of among the values, randomized within ties).
Proof of Proposition 2. (i) is Lemma A.19.
(ii) Under the graphs are i.i.d. By (i) the induced subgraphs are i.i.d., hence exchangeable, and Lemma A.20 applies with . Also , because is counted.
(iii) Given , the edges inside are independent with i.i.d. uniform. So each is a planted partition on vertices with the same , and the blocks are independent. Lemma A.8 with in place of gives the moments, and finally .
(iv) Take the law of with drawn afresh for each graph and . The edge densities of two blocks of the same graph have covariance , while blocks of different graphs are independent, so is not exchangeable. In a simulation with , , , and the edge-density statistic (numerical check (xii)), the level-0.05 test rejects with probability 0.22. Permuting whole graphs remains valid.
A.7 What is not proved
• Sharp constants. Theorem 1(iv) holds with explicit but loose constants. The sharp aligned threshold is cited from Chatterjee et al. [2022] (sparse regime) and not reproved, and in the dense regime we only prove . The asymptotically sharp unaligned constant (Remark 6) relies on the likelihood-ratio limit of Banerjee [2018].
• General finite-rank differences. Only the rank-one and the specific rank-two model are treated. The formula for a general zero-degree finite-rank with normalized eigenvalues is consistent with both cases but is not proved. The Veblen argument needs the positivity of the coefficients , which fails in general.
• Sparse graphs. Theorem 1(i)–(iii) and Proposition 1(i)–(iii) are non-asymptotic and hold for all p. The distributional statements (Theorem 2(ii), Proposition 1(iv) central limit part) are proved for fixed p only.
• Beyond fixed families of signed tree counts. The distributional statement for unsigned tree counts, for degree and colour-refinement histograms with growing support, and for message-passing embeddings at finite n remains a conjecture (Remark 10). Only the graphon-level statement (Remark 8(c)) follows from Theorem 2(i) and the cited characterization.
• Non-constant nulls. There is no lower bound for non-constant W, aligned or unaligned. For differences that are visible at first order we prove upper bounds of the same order for unaligned and aligned tests (Theorem 3(iv) and Proposition 4). For degree-preserving differences orthogonal to a null of finite rank, the rate is a conjecture (Remark 14). The improved variance for F-regular nulls is cited.
• Power of the vertex-split test. Proposition 2 proves validity and computes the signal-to-noise ratio of the within-block statistic. We do not analyse the power of the permutation test itself at small m.
B Experimental details
B.1 Common settings
All experiments ran with NumPy and SciPy on one laptop CPU (10 cores, 16 GB memory), with four worker processes for E11–E14, seven for E15 and three for E16. All data are simulated, except the protein graphs of E16. Wall-clock times were about 24 minutes for E11 and E11b together (E11b reuses the graph pools of E11), 11 minutes for E12 at n = 128 and 66 minutes at n = 256, and 19 minutes for the sparse panel. E13, E14 and E14b took 2, 5 and 2.5 minutes, E15 took 14 minutes and E16 took 8 minutes. The numerical checks of the proofs take about 2 minutes in total. Seeds are fixed and recorded with the results. For every reported rejection rate based on R replicates, the Monte Carlo standard error is , which is at most 0.016 for R = 1000 and 0.035 for R = 200. The sample size is the smallest m at which the power reaches 0.5. It is obtained by log-linear interpolation of the running maximum of the power curve on the grid of m values, and is reported as when the power never reaches 0.5 on the grid.
B.2 Sample complexity, sign cancellation and visibility (E11, E11b, E12)
E11 (sample sizes with and without alignment)
• Model. The null is , and the alternative is the planted partition with and . All tests are one-sided at level 0.05, because every signal is positive.
• Unaligned tests (two-sample, m graphs per group):
– signed triangles with known p and the exact null variance ;
– signed triangles with the pooled edge density;
– the per-graph excess triangle density .
The last two are calibrated by simulated nulls.
• Aligned tests (one shared by the first sample, known ): the statistic with its exact null variance, and the top eigenvalue of calibrated by simulation.
• Pool bootstrap. Unaligned statistics are sums of independent per-graph terms. Their sampling distribution at each m is approximated by resampling m per-graph records with replacement from pools of simulated graphs per model, with 4000 resamples per m. Pools of different models share random numbers. Each pool is still an independent sample from its own model, and sharing reduces the variance of the Monte Carlo error in the pool-mean difference by a factor of 6 to 11.
• Aligned simulation. Aligned tests are simulated replicate by replicate, with 1000 replicates per t. Thresholds use 2000 null replicates and sizes use 1000 held-out ones.
• Checks. All sizes lie in [0.035, 0.066]. The exact null variances of and are confirmed to within 0.3%, and every simulated mean shift agrees with its closed form to within 2.1 standard errors.
• Error bars. Monte Carlo standard errors of come from five batches and are a few per cent. Slopes are least-squares fits with their standard errors.
The sparse panel repeats E11 with n = 2000 and np = 15 (Figure 5).
E11b (sign cancellation). The setting is that of E11, with the rank-two model (4) and the same values of t. Tests are two-sample z-tests with exact null variances for signed triangles and signed 4-cycles. is computed from , and , where . Figure 4 shows the results. Under the rank-one model, 4-cycles also detect the difference, but they need more graphs than triangles (slope ).
E12 (order of visibility)
• Model. The nulls are ER(1/2), SBM2 and SMOOTH, and the alternative is with as in E13 and . We use and repeat the experiment at (Figure 6).
• Unaligned test. The two-sample excess-triangle test, calibrated by simulated nulls from pools of graphs per null.
• Aligned tests. One latent vector is shared by all 2m graphs of a replicate. The Frobenius statistic is with . The spectral statistic is . Both are calibrated by simulated nulls with fresh latent vectors.
• Coefficients. First-order coefficients and exact shifts of are computed by Gauss–Legendre quadrature, which is exact for these piecewise bilinear graphons.


Figure 4: Sign cancellation (E11b), , . Left: against for signed triangles and signed 4-cycles under the rank-one planted partition, and for 4-cycles under the rank-two model (4), where triangles never reach power 0.5. Right: power against at .
B.3 Calibration with few graphs (E13)
Models. The nulls are ER(1/2), SBM2 with within the two halves of and 0.4 across (regular, non-constant), and SMOOTH with (irregular). The alternative adds to the null of the first group, where on , on and its reflection, and on . Its degree function is zero. We use and , with 1000 replicates for size and 500 for power.
Statistic. The per-graph statistic is (with triangles and edges), the negative of the statistic of Gao and Lafferty [2017]. The test statistic is the difference of the group means, and all tests are two-sided at level 0.05.

Figure 5: E11 in the sparse regime (n = 2000, average degree 15). The layout is as in Figure 1.

Figure 6: E12 repeated with n = 256. The layout is as in Figure 2.
Methods
• Graph-label permutation: all splits, enumerated.
• Welch: normal and Student-t (Satterthwaite) calibration.
• Vertex jackknife: leave-one-vertex-out, closed form, normal calibration.
• Vertex split (Proposition 2): contiguous blocks, , enumeration when there are at most 5000 splits and 999 random splits otherwise.
• Rate-extrapolated variance: block variances at sizes and , a fitted exponent clipped to , and extrapolation to size [in the spirit of Bertail et al., 1999].
• ER plug-in: the exact variance of K3R under , derived from its orthogonal expansion in .
• CDB: the graphon multiplier bootstrap of Chatterjee et al. [2026] for and . It is applied to each graph with independent Gaussian multipliers and combined by the delta method, with 999 draws. The regular or irregular form is chosen by their test .
Table 1 summarizes the case , . When the difference is visible at first order (SBM2 null), two conservative variance estimates keep useful power, namely the jackknife and a two-sample version of the multiplier bootstrap of Chatterjee et al. [2026] (CDB). A parametric Erdős–Rényi calibration has more power under the Erdős–Rényi null but size up to 0.49 under SMOOTH, and the Student-t version of the Welch test is valid.
Table 1: Calibration of the two-sample excess-triangle test with graphs per group (, two-sided level 0.05). Size is the largest rejection rate under the three nulls ER(1/2), SBM2 and SMOOTH (1000 replicates, Monte Carlo s.e. 0.007 at 0.05). Power is under (500 replicates). Parentheses mark tests whose size in that cell exceeds 0.064. Figure 7 shows all and .
| Method | Size (worst null) | Power, SBM2 null | Power, ER null | ||||||
|---|---|---|---|---|---|---|---|---|---|
| 2 | 3 | 1 | 2 | 3 | 1 | 2 | 3 | ||
| Graph-label permutation (exact) | 0.000 | 0.000 | 0.000 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 |
| Welch | - | 0.206 | 0.127 | - | (0.85) | (0.96) | - | (0.40) | (0.40) |
| Welch | - | 0.024 | 0.040 | - | 0.22 | 0.69 | - | 0.06 | 0.15 |
| Vertex jackknife | 0.010 | 0.009 | 0.014 | 0.21 | 0.58 | 0.89 | 0.00 | 0.02 | 0.04 |
| Vertex split, (exact) | 0.031 | 0.055 | 0.062 | 0.06 | 0.18 | 0.25 | 0.02 | 0.07 | 0.06 |
| CDB bootstrap | 0.018 | 0.024 | 0.035 | 0.21 | 0.54 | 0.87 | 0.00 | 0.01 | 0.01 |
| ER plug-in (valid under ER only) | 0.482 | 0.488 | 0.458 | (0.82) | (0.96) | (1.00) | 0.18 | 0.30 | 0.41 |
Two caveats about CDB. First, K3R lies outside the theory of Chatterjee et al. [2026] under an Erdős–Rényi null. There its components cancel, and the bootstrap overestimates the variance of the test statistic by a factor of 4.3–5.1, so the test is valid but conservative. Second, at the regularity test never flagged a graph as irregular, even under the irregular SMOOTH null. The bootstrap applied to alone is then anti-conservative under SMOOTH (size 0.18–0.36). With the correct regime its size is 0.023–0.039. This caveat concerns the pre-test at finite , and the asymptotic theorem is unaffected. Figure 7 shows size and power for all methods, nulls, and .
B.4 Graph evaluation metrics (E14, E14b)
Models. In E14 the null is , and the alternative is the planted partition with ( and 0.0260). In E14b, group 1 is the planted partition with and group 2 consists of independent planted-partition graphs, each rewired by successful degree-preserving double-edge swaps (swaps creating loops or multiple edges are rejected). Fresh graphs are drawn in every replicate. We use 200 replicates per point, and sizes are checked at .
Descriptors.
• Degree histogram (degrees 0–60).
• Local clustering histogram (50 bins).
- Counts of edges, 2-paths, triangles, 3-stars, 3-paths and 4-cycles, each divided by its expectation under .
• Normalized-Laplacian eigenvalue histogram (100 bins on [0, 2]).
- A random GIN [Xu et al., 2019] with three layers of width 32, constant input and sum readout of all layers. Without biases, a ReLU GIN with constant input is positively homogeneous, and its features are exact linear functions of three walk counts. We therefore add fixed biases and scale the input by , in the spirit of Thompson et al. [2022].
The MMD uses the unbiased estimator with a Gaussian kernel whose bandwidth is the median pairwise distance of the pooled sample, and is calibrated by 200 label permutations. Signed triangles with the pooled edge density use the same permutations.
Positive controls. Every descriptor rejects in 20/20 replicates against a change of edge density with . Against a degree-heterogeneous graphon with and the same density, the degree histogram and the random GIN have power 1.00 and 1.00 with , and signed triangles have power 0.05. The low power in Figure 3 is therefore caused by the difference itself, since the same embeddings detect a degree-heterogeneous difference.

Figure 7: Size (left two columns, on a square-root axis with a grey band at Monte Carlo s.e.) and power under (right two columns) of the calibration methods, for the three nulls (rows), and . Open markers in the power panels flag methods whose size in that cell exceeds 0.064.
B.5 Evaluation metrics under irregular nulls (E15)
Models. We use three nulls with edge density 0.4 on vertices, namely ER with , SMOOTH with (the irregular null of E12) and the degree-heterogeneous rank-one graphon with , which we call the rank-one null. Their degree functions are 0.4, and . The alternative adds with , where either , which is correlated with the degree profile of the two irregular nulls, or , which is orthogonal to 1 and and hence to every eigenfunction of the three nulls. Both differences have zero degree function, and under the Erdős–Rényi null both are the planted partition with . For , exact quadrature gives first-order coefficients under SMOOTH and under the rank-one null, and and . For , every path density is unchanged and the triangle and 4-cycle densities move by exactly and under all three nulls (Proposition 5).
Descriptors and tests. The descriptors and tests are those of E14 (Section B.4), with one histogram bin per degree and the GIN input scaled by . We add the degree-corrected signed triangle and 4-cycle counts per wedge. With , set to zero on the diagonal, and the number of paths of length two, they are and , compared by the permutation test of the mean difference. We use , 200 replicates per point, and sizes at , which lie between 0.005 and 0.090 for all descriptors and nulls. The value of was chosen in a pilot run with .
Results. Table 2 gives , and the top row of Figure 8 shows power curves. The random GIN detects under both irregular nulls, with under SMOOTH and 25.7 under the rank-one null, through the first-order term of the path with three edges. It stays at the level for under every null and for under the Erdős–Rényi null, with rejection rates between 0.015 and 0.095 over the 24 cells up to (Monte Carlo s.e. 0.015 at 0.05). The degree histogram has the same expected value under both hypotheses for every null, and its rejection rates are at most 0.115. The largest of them, at under SMOOTH with , reflects the joint law of the degrees, which changes at first order when the difference is correlated with the degree profile. Degree-corrected signed triangles and 4-cycles detect every alternative, with power at least 1.00 already at . Signed triangles centred at the pooled edge density, the statistic of Theorem 1, lose power under the rank-one null, where they need graphs for , because the degree heterogeneity of the null enters their variance at first order.
Table 2: E15: graphs per group needed for power 0.5 (, interpolated on , with when reached at and when not reached), and the largest rejection rate under the three nulls (, 200 replicates each).
| Descriptor | ER | SMOOTH | rank-one | Size | |||
|---|---|---|---|---|---|---|---|
| max | |||||||
| Degree histogram (MMD) | >256 | >256 | >256 | >256 | >256 | >256 | 0.070 |
| Random GIN (MMD) | >256 | >256 | 44.3 | >256 | 25.7 | >256 | 0.085 |
| Clustering histogram (MMD) | 28.0 | 38.7 | ≤8 | 191 | ≤8 | >256 | 0.080 |
| Graphlet counts (MMD) | >256 | >256 | 176 | >256 | 124 | >256 | 0.085 |
| Laplacian spectrum (MMD) | 14.5 | 13.5 | 11.7 | 16.7 | 8.9 | 25.8 | 0.090 |
| Signed triangles, pooled | ≤8 | ≤8 | ≤8 | ≤8 | ≤8 | 37.6 | 0.070 |
| Signed triangles, degree-corrected | ≤8 | ≤8 | ≤8 | ≤8 | ≤8 | ≤8 | 0.085 |
| Signed 4-cycles, degree-corrected | ≤8 | ≤8 | ≤8 | ≤8 | ≤8 | ≤8 | 0.080 |
B.6 Protein graphs against rewired copies (E16)
Data. The TUDataset collection [Morris et al., 2020] provides the D&D protein structures [Dobson and Doig, 2003], in which two amino acids are joined when they are less than apart, and the ENZYMES tertiary structures [Borgwardt et al., 2005]. As in the Proteins benchmark of graph generative models [You et al., 2018, Liao et al., 2019] we keep the 918 D&D graphs with 100 to 500 vertices, and as in Jo et al. [2022] the 587 ENZYMES graphs with 10 to 125 vertices after removing isolated vertices. The graphs of a dataset differ in size and shape, and both groups are drawn from the same dataset.
Design. Each replicate draws distinct graphs at random. The first form group 1, and the other form group 2 after of their edges have been rewired by successful degree-preserving double-edge swaps. The three kinds of swaps differ in the pairs of edges they allow. Unrestricted swaps (deg) pick any two edges. Swaps of type w11 pick two edges whose endpoints have equal degrees, and they preserve the colour of every vertex after two rounds of colour refinement. Swaps of type w12 pick two edges whose endpoints have equal colours after two rounds, and they preserve the colours after three rounds. Sequences of such swaps preserve these colours, so under w12 the three-layer GIN returns exactly the embedding of the original graph, which we checked for every rewired graph. Without rewiring the graphs are exchangeable and all tests are exact. In 1200 replicates at their sizes lie between 0.037 and 0.063. The descriptors are those of E14, adapted to graphs of different sizes. We add a GIN with mean readout, and centre the first signed triangle statistic at each graph's own edge density. With no two-sided permutation test can reject at level 0.05, since the smallest attainable -value is , so we report .
Results. Table 3 gives , and the bottom row of Figure 8 shows power curves. Unrestricted rewiring removes of the triangles of the D&D graphs and of those of ENZYMES. The degree histogram and both random GINs stay at the level under deg and w11, with rejection rates of at most 0.075 for all . The signed cycle statistics detect the rewiring with a few graphs. Triangles are the most sensitive on D&D, whose contact graphs are highly clustered, and 4-cycles on ENZYMES. The clustering histogram and the spectrum also detect it on D&D, but need more graphs on ENZYMES. On D&D the -scores of the same signed counts, which grow with the size of the graph, are much weaker, with power 0.28 against 1.00 at for triangles, while on ENZYMES the two normalizations perform alike. We chose the normalization per wedge after comparing the two on rewired D&D graphs in a pilot, which also fixed the rewiring fraction among , so the D&D results favour it by construction. Under w12 only and of the triangles are removed, because two rounds of colour refinement nearly identify the vertices of these graphs. The degree histogram and the random GINs then stay at the level, with rejection rates of at most 0.080, and the signed triangles reach power 0.50 at on D&D.
Table 3: E16: graphs per group needed for power 0.5 (, interpolated on , with when reached at and when not reached) for the three kinds of rewiring, the largest rejection rate without rewiring (, 1200 replicates each), and the share of triangles removed.
| Descriptor | D&D | ENZYMES | Size | ||||
|---|---|---|---|---|---|---|---|
| deg | wl1 | wl2 | deg | wl1 | wl2 | max | |
| Degree histogram (MMD) | >64 | >64 | >64 | >64 | >64 | >64 | 0.058 |
| Random GIN, sum (MMD) | >64 | >64 | >64 | >64 | >64 | >64 | 0.062 |
| Random GIN, mean (MMD) | >64 | >64 | >64 | >64 | >64 | >64 | 0.063 |
| Clustering histogram (MMD) | ≤4 | ≤4 | >64 | 20.4 | 22.4 | >64 | 0.058 |
| Graphlet counts (MMD) | 17.2 | 17.6 | >64 | 15.1 | 20.0 | >64 | 0.060 |
| Laplacian spectrum (MMD) | 4.2 | 4.2 | >64 | 22.6 | 34.1 | >64 | 0.056 |
| Signed triangles, own density | ≤4 | ≤4 | 59.3 | 15.3 | 18.1 | >64 | 0.062 |
| Signed triangles, degree-corrected | ≤4 | ≤4 | 64.0 | 15.6 | 18.4 | >64 | 0.058 |
| Signed 4-cycles, degree-corrected | 4.1 | 4.1 | >64 | 5.7 | 7.6 | >64 | 0.058 |
| Triangles removed | 25% | 25% | 4% | 23% | 21% | 6% | |
degree histogram
random GIN (sum)
random GIN (mean)
clustering histogram
Laplacian spectrum
signed triangles, density-centred
signed triangles, degree-corrected
signed 4-cycles, degree-corrected

Figure 8: Top (E15): rejection rates against for the degree-preserving differences , aligned with the degree profile of the null, and , orthogonal to its eigenfunctions, under SMOOTH and the rank-one null (, ). Bottom (E16): D&D and ENZYMES graphs against copies with of their edges rewired by unrestricted swaps (deg) or by swaps between vertices of equal degree (wl1). Dashed curves are tree statistics, and the grey band is Monte Carlo s.e.
C Extended related work
Two-sample testing for graphs. With aligned vertices, minimax rates are known for two-sample testing of inhomogeneous random graphs [Ghoshdastidar et al., 2020, Chatterjee et al., 2023]. Without alignment, the existing tests compare different kinds of summaries:
• network statistics of one graph per group [Ghoshdastidar et al., 2017];
• latent positions of random dot product graphs [Tang et al., 2017];
• average subgraph counts, with fixed and [Maugis et al., 2020];
• graph cumulants, which remove lower-order effects and improve power at small sample sizes [Bravo-Hermsdorff et al., 2023];
• Edgeworth-corrected motif statistics for two networks [Shao et al., 2026];
• block-model and graphon estimates [Nguen et al., 2025, Sabanayagam et al., 2021, Chen et al., 2019];
• joint laws of subsampled moments [Qi et al., 2024].
Ghoshdastidar et al. [2017] prove minimax optimality for tests built on a given statistic, with a single graph per group. Our lower bounds cover all tests and any number of graphs. Their hard instance (Theorem 10 of Ghoshdastidar et al. [2017]) is essentially our alternative. It compares the Erdős–Rényi graph with a uniform mixture of two-block models over exactly balanced labellings, with edge probabilities within and between the blocks, which is the planted partition (1) with up to the balancing of the labels. They show that the total variation distance between the two models tends to zero when , that is, when , so that no test with one graph per group has a small total error. Theorem 1(i) makes this quantitative for graphs per group, since for every graph size and every a test with errors needs graphs, and signed triangles attain this order (Theorem 1(ii)). The excess triangle statistic in our experiments is the statistic of Gao and Lafferty [2017]. We use existing statistics and characterize when they are optimal and what they cost. The effect of shuffled labels on the power of aligned tests is studied by Saxena and Lyzinski [2025]. Chen et al. [2026] observe that misalignment hurts changepoint localization when the change lies in the joint law of the latent positions, and is nearly harmless when it lies in their marginal law. This is close in spirit to our distinction between orders of visibility.
Detection thresholds and small subgraphs. Contiguity of block models and Erdős–Rényi graphs below the Kesten–Stigum threshold, and the role of cycle counts, are due to Mossel et al. [2015], Banerjee [2018] and Banerjee and Ma [2017], building on small subgraph conditioning [Janson, 1995]. The multilayer, aligned analogue is treated by Chatterjee et al. [2022]. Other one-graph problems where the choice of cycle order matters include:
• signed polygons for degree-corrected models [Jin et al., 2021];
• latent geometry, where signed triangles can be optimal [Bubeck et al., 2016] or suboptimal compared with 4-cycles [Bangachev and Bresler, 2024];
• planted subgraphs [Yu et al., 2025, Elimelech and Huleihel, 2025].
Correlation detection between unlabeled graphs [Wu et al., 2023, Mao et al., 2024, Ding et al., 2025, Ameen and Hajek, 2025] asks whether two graphs share a hidden alignment, which is a different problem from ours.
Invariant polynomials and low-degree methods. Low-degree lower bounds exploit invariance under relabelling, and invariant polynomials are combinations of subgraph counts [Kunisky et al., 2019, 2024, Carpentier et al., 2025]. Testing between two structured models has recently been studied in this framework for one graph [Rush et al., 2026, Skeja et al., 2026]. Our lower bounds are information-theoretic and exploit independence across graphs.
Fluctuations of subgraph counts. The fluctuations of subgraph counts in graphon models are Gaussian at scale when the graphon is irregular with respect to the motif. When it is regular, they are of smaller order and possibly non-Gaussian [Hladký et al., 2021, Bhattacharya et al., 2023, Kaur and Röllin, 2021, Chatterjee et al., 2026]. Resampling methods for network moments include Green and Shalizi [2022], Lin et al. [2020] and Zhang and Xia [2022].
Learned two-sample tests and graph neural networks. Kernel and learned two-sample tests [Gretton et al., 2012, Liu et al., 2020, 2021, Kirchler et al., 2020, Kübler et al., 2022] become permutation-invariant graph tests once the features are invariant. The expressive power of message passing on graphons is characterized by tree densities [Grebík and Rocha, 2022, Böker, 2023, Böker et al., 2023]. The same features are used to evaluate graph generative models [You et al., 2018, O'Bray et al., 2022, Thompson et al., 2022, Krimmel et al., 2025].