Year: 2021

Abstract:
We propose data-driven one-pass streaming algorithms for estimating the number of triangles and four cycles, two fundamental problems in graph analytics that are widely studied in the graph data stream literature. Recently, Hsu et al. (2019a) and Jiang et al. (2020) applied machine learning techniques in other data stream problems, using a trained oracle that can predict certain properties of the stream elements to improve on prior “classical” algorithms that did not use oracles. In this paper, we explore the power of a “heavy edge” oracle in multiple graph edge streaming models. In the adjacency list model, we present a one-pass triangle counting algorithm improving upon the previous space upper bounds without such an oracle. In the arbitrary order model, we present algorithms for both triangle and four cycle estimation with fewer passes and the same space complexity as in previous algorithms, and we show several of these bounds are optimal. We analyze our algorithms under several noise models, showing that the algorithms perform well even when the oracle errs. Our methodology expands upon prior work on “classical” streaming algorithms, as previous multi-pass and random order streaming algorithms can be seen as special cases of our algorithms, where the first pass or random order was used to implement the heavy edge oracle. Lastly, our experiments demonstrate advantages of the proposed method compared to state-of-theart streaming algorithms.

heading: 1 INTRODUCTION
text: Counting the number of cycles in a graph is a fundamental problem in the graph stream model (e.g., Atserias et al. (2008); Bera & Chakrabarti (2017); Seshadhri et al. (2013); Kolountzakis et al. (2010); Bar-Yossef et al. (2002); Kallaugher et al. (2019)). The special case of counting triangles is widely studied, as it has a vast range of applications. In particular, it provides important insights into the structural properties of networks (Prat-Pérez et al., 2012; Farkas et al., 2011), and is used to discover motifs in protein interaction networks (Milo et al., 2002), understand social networks (Foucault Welles et al., 2010), and evaluate large graph models (Leskovec et al., 2008). See Al Hasan & Dave (2018) for a survey of these and other applications.
Because of its importance, a large body of research has been devoted to space-efficient streaming algorithms for (1 + )-approximate triangle counting. Such algorithms perform computation in one or few passes over the data using only a sub-linear amount of space. A common difficulty which arises in all previous works is the existence of heavy edges, i.e., edges that are incident to many triangles (four cycles). As sublinear space algorithms often rely on sampling of edges, and since a single heavy edge can greatly affect the number of triangles (four cycles) in a graph, sampling and storing these edges are often the key to an accurate estimation. Therefore, multiple techniques have been developed to determine whether a given edge is heavy or not.
Recently, based on the observation that many underlying patterns in real-world data sets do not change quickly over time, machine learning techniques have been incorporated into the data stream model via the training of heavy-hitter oracles. Given access to such a learning-based oracle, a wide range of significant problems in data stream processing — including frequency estimation, estimating the number of distinct elements, Fp-Moments or (k, p)-Cascaded Norms — can all achieve space bounds that are better than those provided by “classical” algorithms, see, e.g., Hsu et al. (2019a); Cohen et al. (2020); Jiang et al. (2020); Eden et al. (2021); Du et al. (2021). More gen-
erally, learning-based approaches have had wide success in other algorithmic tasks, such as data structures (Kraska et al., 2018; Ferragina et al., 2020; Mitzenmacher, 2018; Rae et al., 2019; Vaidya et al., 2021), online algorithms (Lykouris & Vassilvtiskii, 2018; Purohit et al., 2018; Gollapudi & Panigrahi, 2019; Rohatgi, 2020; Wei, 2020; Mitzenmacher, 2020; Lattanzi et al., 2020; Bamas et al., 2020), similarity search (Wang et al., 2016; Dong et al., 2020) and combinatorial optimization (Dai et al., 2017; Balcan et al., 2017; 2018a;b; 2019). See the survey and references therein for additional works (Mitzenmacher & Vassilvitskii, 2020).
Inspired by these recent advancements, we ask: is it possible to utilize a learned heavy edge oracle to improve the space complexity of subgraph counting in the graph stream model? Our results demonstrate that the answer is yes.

heading: 1.1 OUR RESULTS AND COMPARISON TO PREVIOUS THEORETICAL WORKS
text: We present theoretical and empirical results in several graph streaming models, and with several notions of prediction oracles. Conceptually, it is useful to begin by studying perfect oracles that provide exact predictions. While instructive theoretically, such oracles are typically not available in practice. We then extend our theoretical results to noisy oracles that can provide inaccurate or wrong predictions. We validate the practicality of such oracles in two ways: by directly showing they can be constructed for multiple real datasets, and by showing that on those datasets, our algorithms attain significant empirical improvements over baselines, when given access to these oracles.
We proceed to a precise account of our results. Let G = (V,E) denote the input graph, and let n, m, and T denote the number of vertices, edges, and triangles (or four-cycles) in G, respectively. There are two major graph edge streaming models: the adjacency list model and the arbitrary order model. We show that training heavy edge oracles is possible in practice in both models, and that such oracles make it possible to design new algorithms that significantly improve the space complexity of triangle and four-cycle counting, both in theory and in practice. Furthermore, our formalization of a heavy edge prediction framework makes it possible to show provable lower bounds as well. Our results are summarized in Table 1.
In our algorithms, we assume that we know a large-constant approximation of T for the purposes of setting various parameters. This is standard practice in the subgraph counting streaming literature (e.g., see (Braverman et al., 2013, Section 1), (McGregor et al., 2016, Section 1.2) for an extensive discussions on this assumption). Moreover, when this assumption cannot be directly carried over in practice, in Subsection F.3 we discuss how to adapt our algorithms to overcome this issue.

heading: 1.1.1 PERFECT ORACLE
text: Our first results apply for the case that the algorithms are given access to a perfect heavy edge oracle. That is, for some threshold ρ, the oracle perfectly predicts whether or not a given edge is incident to at least ρ triangles (four cycles). We describe how to relax this assumption in Section 1.1.2.
Adjacency List Model All edges incident to the same node arrive together. We show: Theorem 1.1. There exists a one-pass algorithm, Algorithm 1, with space complexity1 Õ(min( −2m2/3/T 1/3, −1m1/2)) in the adjacency list model that, using a learning-based oracle, returns a (1± )-approximation to the number T of triangles with probability at least2 7/10.
An overview of Algorithm 1 is given in Section 2, and the full analysis is provided in Appendix B. Arbitrary Order Model In this model, the edges arrive in the stream in an arbitrary order. We present a one-pass algorithm for triangle counting and another one-pass algorithm for four cycle counting in this model, both reducing the number of passes compared to the currently best known space complexity algorithms. Our next result is as follows: Theorem 1.2. There exists a one-pass algorithm, Algorithm 4, with space complexity Õ( −1(m/ √ T + √ m)) in the arbitrary order model that, using a learning-based oracle, returns a (1± )-approximation to the number T of triangles with probability at least 7/10. 1We use Õ(f) to denote O(f · polylog(f)). 2For all of our algorithms, the success probability can be replaced by 1 − δ by running log(1/δ) copies of the algorithm and taking the median.
An overview of Algorithm 4 is given in Section 3, and full details are provided in Appendix C.
We also show non-trivial space lower bounds that hold even if appropriate predictors are available. In Theorem C.2 in Appendix C.3, we provide a lower bound for this setting by giving a construction that requires Ω(min(m/ √ T ,m3/2/T )) space even with the help of an oracle, proving that our result is nearly tight in some regimes. Therefore, the triangle counting problem remains non-trivial even when extra information is available.
Four Cycle Counting. For four cycle counting in the arbitrary order model, we give Theorem 1.3 which is proven in Appendix D.
Theorem 1.3. There exists a one-pass algorithm, Algorithm 5, with space complexity Õ(T 1/3 + −2m/T 1/3) in the arbitrary order model that, using a learning-based oracle, returns a (1 ± )- approximation to the number T of four cycles with probability at least 7/10.
To summarize our theoretical contributions, for the first set of results of counting triangles in the adjacency list model, our bounds always improve on the previous state of the art due to McGregor et al. (2016) for all values of m and T . For a concrete example, consider the case that T = Θ( √ m).
In this setting previous bounds result in an Õ(m3/4)-space algorithm, while our algorithm only requires Õ( √ m) space (for constant ).
For the other two problems of counting triangles and 4-cycles in the arbitrary arrival model, our space bounds have an additional additive term compared to McGregor et al. (2016) (for triangles) and Vorotnikova (2020) (for 4-cycles) but importantly run in a single pass rather than multiple passes. In the case where the input graph has high triangles density, T = Ω(m/ 2), our space bound is worse due to the additive factor. When T = O(m/ 2), our results achieve the same dependence on m and T as that of the previous algorithms with an improved dependency in . Moreover, the case T ≤ m/ 2 is natural for many real world datasets: for = 0.05, this condition holds for all of the datasets in our experimental results (see Table 2). Regardless of the triangle density, a key benefit of our results is that they are achieved in a single pass rather than multiple passes. Finally, our results are for general graphs, and make no assumptions on the input graph (unlike Pagh & Tsourakakis (2012); Kallaugher & Price (2017); Bera & Sheshadhri (2020)). Most of our algorithms are relatively simple and easy to implement and deploy. At the same time, some of our results require the use of novel techniques in this context, such as the use of exponential random variables (see Section 2).

heading: 1.1.2 NOISY ORACLES
text: The aforementioned triangle counting results are stated under the assumption that the algorithms are given access to perfect heavy edge oracles. In practice, this assumption is sometimes unrealistic. Hence, we consider several types of noisy oracles. The first such oracle, which we refer to as a K-noisy oracle, is defined below (see Figure 4 in the Supplementary Section C.2). Definition 1.1. For an edge e = xy in the stream, define Ne as the number of triangles that contain both x and y. For a fixed constant K ≥ 1 and for a threshold ρ we say that an oracle Oρ is a K-noisy oracle if for every edge e, 1−K · ρNe ≤ Pr[Oρ(e) = HEAVY] ≤ K · Ne ρ .
This oracle ensures that if an edge is extremely heavy or extremely light, it is classified correctly with high probability, but if the edge is close to the threshold, the oracle may be inaccurate. We further discuss the properties of this oracle in Section G.
For this oracle, we prove the following two theorems. First, in the adjacency list model, we prove: Theorem 1.4. Suppose that the oracle given to Algorithm 1 is a K-noisy oracle as defined in Definition 1.1. Then with probability 2/3, Algorithm 1 returns a value in (1 ± √ K· )T , and uses space at most Õ(min( −2m2/3/T 1/3,K· −1m1/2)).
Hence, even if our oracle is inaccurate for edges near the threshold, our algorithm still obtains an effective approximation with low space in the adjacency list model. Likewise, for the arbitrary order model, we prove in Theorem C.1 that the O( −1(m/ √ T + √ m)) 1-pass algorithm of Theorem 1.2 also works when Algorithm 4 is only given access to a K-noisy oracle.
The proof of Theorem 1.4 is provided in Appendix B.1, and the proof of Theorem C.1 is provided in Appendix C.2. We remark that Theorems 1.4 and C.1 automatically imply Theorems 1.1 and 1.2, since the perfect oracle is automatically a K-noisy oracle.
(Noisy) Value Oracles In the adjacency list model, when we see an edge xy, we also have access to all the neighbors of either x or y, which makes it possible for the oracle to give a more accurate prediction. For an edge xy, let Rxy denote the number of triangles {x, z, y} so that x precedes z and z precedes y in the stream arrival order. Formally, Rxy = |z : {x, y, z} ∈ ∆ and x <s z <s y| where x <s y denotes that the adjacency list of x arrives before that of y in the stream.
Motivated by our empirical results in Section F.7, it is reasonable in some settings to assume we have access to oracles that can predict a good approximation to Rxy . We refer to such oracles as value oracles.
In the first version of this oracle, we assume that the probability of approximation error decays linearly with the error from above but exponentially with the error from below. Definition 1.2. Given an edge e, an (α, β) value-prediction oracle outputs a random value p(e) where E[p(e)] ≤ αRe + β, and Pr[p(e) < Reλ − β] ≤ Ke −λ for some constant K and any λ ≥ 1.
For this variant, we prove the following theorem. Theorem 1.5. Given an oracle with parameters (α, β), there exists a one-pass algorithm, Algorithm 2, with space complexity O( −2 log2(K/ )(α + mβ/T )) in the adjacency list model that returns a (1± )-approximation to the number of triangles T with probability at least 7/10.
In the second version of this noisy oracle, we assume that the probability of approximation error decays linearly with the error from both above and below. For this variant, we prove that we can achieve the same guarantees as Theorem 1.5 up to logarithmic factors (see Theorem B.1). The algorithms and proofs for both Theorem 1.5 and Theorem B.1 appear in Appendix B.2.
Experiments We conduct experiments to verify our results for triangle counting on a variety of real world networks (see Table 2) in both the arbitrary and adjacency list models. Our algorithms use additional information through predictors to improve empirical performance. The predictors are data dependent and include: memorizing heavy edges in a small portion of the first graph in a sequence of graphs, linear regression, and graph neural networks (GNNs). Our experimental results show that we can achieve up to 5x decrease in estimation error while keeping the same amount of edges as other state of the art empirical algorithms. For more details, see Section 4. In Section F.7, we show that our noisy oracle models are realistic for real datasets.
Related Empirical Works On the empirical side, most of the focus has been on triangle counting in the arbitrary order model for which there are several algorithms that work well in practice. We primarily focus on two state-of-the-art baselines, ThinkD (Shin et al., 2018) and WRS (Shin, 2017). In these works, the authors compare to previous empirical benchmarks such as the ones given in Stefani et al. (2017); Han & Sethu (2017); Lim & Kang (2015) and demonstrate that their algorithms achieve superior estimates over these benchmarks. There are also other empirical works such as Ahmed et al. (2017) and Ahmed & Duffield (2020) studying this model but they do not compare to either ThinkD or WRS. While these empirical papers demonstrate that their algorithm returns unbiased estimates, their theoretical guarantees on space is incomparable to the previously stated space bounds for theoretical algorithms in Table 1. Nevertheless, we use ThinkD and WRS as part of our benchmarks due to their strong practical performance and code accessibility. Implicit Predictors in Prior Works The idea of using a predictor is implicit in many prior works. The optimal two pass triangle counting algorithm of McGregor et al. (2016) can be viewed as an implementation of a heavy edge oracle after the first pass. This oracle is even stronger than the Knoisy oracle as it is equivalent to an oracle that is always correct on an edge e if Ne either exceeds or is under the threshold ρ by a constant multiplicative factor. This further supports our choice of oracles in our theoretical results, as a stronger version of our oracle can be implemented using one additional pass through the data stream (see Section G). Similarly, the optimal triangle counting streaming algorithm (assuming a random order) given in McGregor & Vorotnikova (2020) also implicitly defines a heavy edge oracle using a small initial portion of the random stream (see Lemma 2.2 in McGregor & Vorotnikova (2020)). The random order assumption allows for the creation of such an oracle since heavy edges are likely to have many of their incident triangle edges appearing in an initial portion of the stream. We view these two prior works as theoretical justification for our oracle definitions. Lastly, the WRS algorithm also shares the feature of defining an implicit oracle: some space is reserved for keeping the most recent edges while the rest is used to keep a random sample of edges. This can be viewed as a specific variant of our model, where the oracle predicts recent edges as heavy. Preliminaries. G = (V,E) denotes the input graph, and n, m and T denote the number of vertices, edges and triangles (or four-cycles) inG, respectively. We useN(v) to denote the set of neighbors of a node v, and ∆ to denote the set of triangles. In triangle counting, for each xy ∈ E(G), we recall that Nxy = |z : {x, y, z} ∈ ∆| is the number of triangles incident to edge xy, and Rxy = |z : {x, y, z} ∈ ∆, x <s z <s y| is the number of triangles adjacent to xy with the third vertex z of the triangle between x and y in the adjacency list order. Table A summarizes the notation.

heading: 2 TRIANGLE COUNTING IN THE ADJACENCY LIST MODEL
text: We describe an algorithm with a heavy edge oracle, and one with a value oracle. Heavy Edge Oracle. We present an overview of our one-pass algorithm, Algorithm 1, with a space complexity of Õ(min( −2m2/3/T 1/3, −1m1/2)), given in Theorem 1.1. We defer the pseudocode and proof of the theorem to Appendix B. The adaptations and proofs for Theorems 1.4, 1.5 and B.1 for the various noisy oracles appear in Appendix B.1 and Appendix B.2.
Our algorithm works differently depending on the value of T . We first consider the case that T ≥ (m/ )1/2. Assume that for each sampled edge xy in the stream, we can exactly know the number of trianglesRxy this edge contributes to T . Then the rate at which we would need to sample each edge would be proportional to pnaive ≈ −2∆E/T , where ∆E is the maximum number of triangles incident to any edge. Hence, our first idea is to separately consider light and non-light edges using the heavy edge oracle. This allows us to sample edges that are deemed light by the oracle at a lower rate, p1, and compute their contribution by keeping track of Rxy for each such sampled edge. Intuitively, light edges offer us more flexibility and thus we can sample them with a lower probability while ensuring the estimator’s error does not drastically increase. In order to estimate the contribution due to non-light edges, we again partition them into two types: medium and heavy, according to some threshold ρ. We then use an observation from McGregor et al. (2016), that since for heavy edges Rxy > ρ, it is sufficient to sample from the entire stream at rate p3 ≈ −2/ρ, in order to both detect if some edge xy is heavy and if so to estimate Rxy .
Therefore, it remains to estimate the contribution to T due to medium edges (these are the edges that are deemed non-light by the oracle, and also non-heavy according to the sub-sampling above).
Since the number of triangles incident to medium edges is higher than that of light ones, we have to sample them at some higher rate p2 > p1. However, since their number is bounded, this is still space efficient. We get the desired bounds by correctly setting the thresholds between light, medium and heavy edges.
When T < (m/ )1/2 our algorithm becomes much simpler. We only consider two types of edges, light and heavy, according to some threshold T/ρ. To estimate the contribution due to heavy edges we simply store them and keep track of their Rxy values. To estimate the contribution due to light edges we sub-sample them with rate −2 ·∆E/T = −2/ρ. The total space we use is Õ( −1 √ m), which is optimal in this case. See Algorithm 1 for more details of the implementation.
Value-Based Oracle. We also consider the setting where the predictor returns an estimate p(e) of Re, and we assume Re ≤ p(e) ≤ α · Re, where α ≥ 1 is an approximation factor. We relax this assumption to also handle additive error as well as noise, but for intuition we focus on this case. The value-based oracle setting requires the use of novel techniques, such as the use of exponential random variables (ERVs). Given this oracle, for an edge e, we compute p(e)/ue, were ue is a standard ERV. We then store the O(α log(1/ )) edges e for which p(e)/ue is largest. Since we are in the adjacency list model, once we start tracking edge e = xy, we can also compute the true value Re of triangles that the edge e participates in (since for each future vertex z we see, we can check if x and y are both neighbors of z). Note that we track this quantity only for the O(α log(1/ )) edges that we store. Using the max-stability property of ERVs, maxeRe/ue is equal in distribution to T/u, where u is another ERV. Importantly, using the density function of an ERV, one can show that the edge e for which Re/ue is largest is, with probability 1 − O( 3), in our list of the O(α log(1/ )) largest p(e)/ue values that we store. Repeating this scheme r = O(1/ 2) times, we obtain independent estimates T/u1, . . . , T/ur, where u1, . . . , ur are independent ERVs. Taking the median of these then gives a (1 ± )-approximation to the total number T of triangles. We note that ERVs are often used in data stream applications (see, e.g., Andoni (2017)), though to the best of our knowledge they have not previously been used in the context of triangle estimation. We also give an alternative algorithm, based on subsampling at O(log n) scales, which has worse logarithmic factors in theory but performs well empirically.

heading: 3 TRIANGLE COUNTING IN THE ARBITRARY ORDER MODEL
text: In this section we discuss Algorithm 4 for estimating the number of triangles in an arbitrary order stream of edges. The pseudo-code of the algorithm as well as omitted proofs for the different oracles are given in Supplementary Section C. Here we give the intuition behind the algorithm. Our approach relies on sampling the edges of the stream as they arrive and checking if every new edge forms a triangle with the previously sampled edges. However, as previously discussed, this approach alone fails if some edges have a large number of triangles incident to them as “overlooking” such edges might lead to an underestimation of the number of triangles. Therefore, we utilize a heavy edge oracle, and refer to edges that are not heavy as light. Whenever a new edge arrives, we first query the oracle to determine if the edge is heavy. If the edge is heavy we keep it, and otherwise we sample it with some probability. As in the adjacency list arrival model case, this strategy allows us to reduce the variance of our estimator. By balancing the sampling rate and our threshold for heaviness, we ensure that the space requirement is not too high, while simultaneously guaranteeing that our estimate is accurate.
In more detail, our algorithm works as follows. First, we set a heaviness threshold ρ, so that if we predict an edge e to be part of ρ or more triangles, we label it as heavy. We also set a sampling parameter p. We let H be the set of edges predicted to be heavy and let SL be a random sample of edges predicted to be light. Then, we count three types of triangles. The first counter, `1, counts the triangles ∆ = (e1, e2, e), where the first two edges seen in this triangle by the algorithm, represented by e1 and e2, are both in SL. Note that we only count the triangle if e1 and e2,were both in SL at the time e arrives in the stream. Similarly, `2 counts triangles whose first two edges are in SL and H (in either order), and `3 counts triangles whose first two edges are in H . Finally, we return the estimate ` = `1/p2 + `2/p + `3. Note that if the first two edges in any triangle are light, they will both be in SL with probability p2, and if exactly one of the first two edges is light, it will be in SL with probability p. Therefore, we divide `1 by p2 and `2 by p so that ` is an unbiased estimator.

heading: 4 EXPERIMENTS
text: We now evaluate our algorithm on real and synthetic data whose properties are summarized in Table 2 (see Appendix F for more details).
We now describe the edge heaviness predictors that we use (see also Table 2). Our predictors adapt to the type of dataset and information available for each dataset. Some datasets we use contain only the graph structure (nodes and edges) without semantic features, thus not enabling us to train a classical machine learning predictor for edge heaviness. In those cases we use the true counts on a small prefix of the data (either 10% of the first graph in a sequence of graphs, or a prefix of edges in a temporal graph) as predicted counts for subsequent data. However, we are able to create more sophisticated predictors on three of our datasets, using feature vectors in linear regression or a Graph Neural Network. Precise details of the predictors follow.
• Snapshot: For Oregon / CAIDA graph datasets, which contain a sequence of graphs, we use exact counting on a small fraction of the first graph as the predictor for all the subsequent graphs. Specifically, we count the number of triangles per edge, Ne, on the first graph for each snapshot dataset. We then only store 10% of the top heaviest edges and use these values as estimates for edge heaviness in all later graphs. If a queried edge is not stored, its predicted Ne value is 0.
• Prefix: In the WikiBooks temporal graph, we use the exact Ne counts on the first half of the graph edges (when sorted by their timestamps) as the predicted values for the second half.
• Linear Regression: In the Reddit Hyperlinks temporal graph, we use a separate dataset (Kumar et al., 2019) that contains 300-dimensional feature embeddings of subreddits (graph nodes). Two embeddings are close in the feature space if their associated subreddits have similar sub-communities. To produce an edge f(e) embedding for an edge e = uv from the node embedding of its endpoints, f(u) and f(v), we use the 602-dimensional embedding (f(u), f(v), ‖(f(u)− f(v)‖1 , ‖(f(u)− f(v)‖2). We then train a linear regressor to predict Ne given the edge embedding f(e). Training is done on a prefix of the first half of the edges.
• Link Prediction (GNN): For each of the two networks, we start with a graph that has twice as many edges as listed in Table 2, (∼ 1.1 · 105 edges for Twitch and 9.2 · 104 edges for Wikipedia). We then randomly remove 50% of the total edges to be the training data set, and use the remaining edges as the graph we test on. We use the method proposed in Zhang & Chen (2018) to train a link prediction oracle using a Graph Neural Network (GNN) that will be used to predict the heaviness of the testing edges. For each edge that arrives in the stream of the test edges, we use the predicted likelihood of forming an edge given by the the neural network to the other vertices as our estimate
for Nuv , the number of triangles on edge uv. See Section F.2 for details of training methodology.
• Expected Value (EV): In the Powerlaw graph, the predicted number of triangles incident to each Ne is its expected value, which can be computed analytically in the CLV random graph model.
Baselines. We compare our algorithms with the following baselines. • ThinkD and WRS (Arbitrary Order): These are the state of the art empirical one-pass algorithms from Shin et al. (2018) and Shin (2017) respectively. The ThinkD paper presents two versions of the algorithm, called ‘fast’ and ‘accurate’. We use the ‘accurate’ version since it provides better estimates. We use the authors’ code for our experiments (Shin et al., 2020; Shin, 2020).
• MVV (Arbitrary Order and Adjacency List): We use the one pass streaming algorithms given in McGregor et al. (2016) for the arbitrary order model and the adjacency list model.
Error measurement. We measure accuracy using the relative error |1− T̃ /T |, where T is the true triangle count and T̃ is the estimate returned by an algorithm. Our plots show the space used by an algorithm (in terms of the number of edges) versus the relative error. We report median errors over 50 independent executions of each experiment, ± one standard deviation.

heading: 4.1 RESULTS FOR ARBITRARY ORDER TRIANGLE COUNTING EXPERIMENTS
text: In this section, we give experimental results for Algorithm 4 which approximates the triangle count in arbitrary order streams. Note that we need to set two parameters for Algorithm 4: p, which is the edge sampling probability, and ρ, which is the heaviness threshold. In our theoretical analysis, we assume knowledge of a lower bound on T in order to set p and ρ, as is standard in the theoretical streaming literature. However, in practice, such an estimate may not be available; in most cases, the only parameter we are given is a space bound for the number of edges that can be stored. To remedy this discrepancy, we modify our algorithm slightly by setting a fixed fraction of space to use for heavy edges (10% of space for all of our experiments) and setting p correspondingly to use up the rest of the space bound given as input. See details in Supplementary Section F.3.
Oregon and CAIDA In Figures 1(a) and 1(b), we display the relative error as a function of increasing space for graph #4 in the dataset for Oregon and graph #30 for CAIDA 2006. These figures show that our algorithm outperforms the other baselines by as much as a factor of 5. We do not display the error bars for MVV and WRS for the sake of visual clarity, but they are comparable to or larger than both ThinkD and our algorithm. A similar remark applies to all figures in Figure 1. As shown in Figure 2, these specific examples are reflective of the performance of our algorithm across the whole sequence of graphs for Oregon and CAIDA. We also show qualitatively similar results for CAIDA 2007 in Figure 5(a) in Supplementary Section F.4.
We also present accuracy results over the various graphs of the Oregon and CAIDA datasets. We fix the space to be 10% of the number of edges (which varies across graphs). Our results for the Oregon dataset are plotted in Figure 2(a) and the results for CAIDA 2006 and 2007 are plotted in Figures 2(b) and 2(c), respectively. These figures illustrate that the quality of the predictor remains consistent over time even after a year has elapsed between when the first and the last graphs were created as our algorithm outperforms the baselines on average by up to a factor of 2.
Reddit Our results are displayed in Figure 1(c). All four algorithms are comparable as we vary space. While we do not improve over baselines in this case, this dataset serves to highlight the fact that predictors can be trained using node or edge semantic information (i.e., features).
Wikibooks and Powerlaw For Wikibooks, we see in Figure 1(d) that our algorithm is outperforming ThinkD and WRS by at least a factor of 2, and these algorithms heavily outperform the MVV algorithm. Nonetheless, it is important to note that our algorithm uses the exact counts on the first half of the edges (encoded in the predictor), which encode a lot information not available to the baselines. Thus the takeaway is that in temporal graphs, where edges arrive continuously over time (e.g., citation networks, road networks, etc.), using a prefix of the edges to form noisy predictors can lead to a significant advantage in handling future data on the same graph. Our results for Powerlaw are presented in Figure 1(f). Here too we see that as the space allocation increases, our algorithm outperforms ThinkD, MVV, and WRS.
Twitch and Wikipedia In Figure 1(e), we see that three algorithms, ours, MVV, and WRS, are all comparable as we vary space. The qualitatively similar result for Twitch is given in Figure 5(b). These datasets serve to highlight that predictors can be trained using modern ML techniques such as Graph Neural Networks. Nevertheless, these predictors help our algorithms improve over baselines for experiments in the adjacency list model (see Section below).
Results for Adjacency List Experiments We also briefly present experimental results for triangle counting in adjacency list streams. Similarly to the arbitrary order experiments, for our learningbased algorithm, we reserve the top 10% of the total space for storing the heavy edges. We also consider a multi-layer sub-sampling version of the algorithm in Section B.2. Here we use more information from the oracle by adapting the sub-sampling rates of edges based on their predicted value. For more details, see Section F.5. Our results are presented in Figure 3 (with additional plots given in Figure 7). Our algorithms soundly outperform the MVV baseline for most graph datasets. We only show the error bars for the multi-layer algorithm and MVV for clarity.

heading: A NOTATIONS TABLE
text: Notation Definition
G = (V,E) a graph G with vertex set V and edge set E
n number of triangles
m number of edges
T number of triangles (or 4-cycles)
approximation parameter
<s total ordering on the vertices according to their arrival in the adjacency list arrival model
∆ set of triangles in G
set of 4-cycles in G
N(v) set of neighbors of node v
Nxy number of triangles (4-cycles) incident to edge xy, i.e., |{z|(x, y, z) ∈ ∆}| ( |{w, z|(x, y, w.z) ∈ }| )
Rxy
number of triangles (x, z, y) where x precedes z and z precedes y in the adjacency list arrival model, i.e., |{z|(x, z, y) ∈ ∆, x <s z <s y}|
∆E maximum number of triangles incident to any edge
∆V maximum number of triangles incident to any vertex
Oρ heavy edge oracle with threshold ρ

heading: B OMITTED PROOFS FROM SECTION 2
text: In this section, we prove correctness and bound the space of Algorithm 1, thus proving Theorem 1.1. In the adjacency list model, recall that we have a total ordering on nodes <s based on the stream ordering, where x <s y if and only if the adjacency list of x arrives before the adjacency list of y in the stream. For each xy ∈ E(G), we define Rxy = |z : {x, y, z} ∈ ∆ and x <s z <s y|. Note that if y <s x, then Rxy = 0. It holds that ∑ xy∈E Rxy = T .
We first give a detailed overview of the algorithm. We first consider the case when T ≥ (m/ )1/2. Let ρ = (mT )1/3. We define the edge xy to be heavy if Rxy ≥ ρ, light if Rxy ≤ Tρ , and medium if T ρ < Rxy < ρ. We train the oracle to predict, upon seeing xy, whetherRxy is light or not. We define H,M , and L as the set of heavy, medium, and light edges, respectively. Define TL = ∑ xy∈LRxy .
We define TH and TM similarly. Since ∑ xy∈E Rxy = T = TL + TM + TH , it suffices to estimate each of these three terms.
For the light edges, as shown in Lemma B.2, if we sample edges with rate p1 ≈ −2/ρ, with high probability we obtain an estimate of TL within error ± T . For the heavy edges, we recall an observation in McGregor et al. (2016): for an edge xy where Rxy is large, even if we do not sample xy directly, if we sample from the stream (at rate p3 ≈ −2/ρ), we are likely to sample some edges in the set |xz : {x, y, z} ∈ ∆ and x <s z <s y|. We refer to the sampled set of these edges as Saux. Further, we will show that not only can we use Saux to recognize whether Rxy is large, but also to estimateRxy (Lemma B.3). What remains to handle is the medium edges. Since medium edges have higher values ofRxy than light edges, we sample with a larger rate, p2, to reduce variance. However, we show there cannot be too many medium edges, so we do not pay too much extra storage space. The overall space we use is Õ( −2m2/3/T 1/3). When T < (m/ )1/2 our algorithm becomes much simpler. Let ρ = √ m/ . We define the edge xy to be heavy if Rxy ≥ T/ρ, and light otherwise (so in this case all the medium edges become heavy edges). We directly store all the heavy edges and sub-sample with rate −2/ρ to estimate TL. The total space we use is Õ( −1 √ m), which is optimal in this case. See Algorithm 1 for more details of the implementation.
Remark B.1. In the adjacency list model, we assume the oracle can predict whether Rxy ≥ Tc or not, where Rxy is dependent on the node order. This may sometimes be impractical. However, observe that Nxy ≥ Rxy and ∑ Nxy = 3T . Hence, our proof still holds if we assume what the oracle can predict is whether Nxy ≥ Tc , which could be a more practical assumption.
Recall the following notation from Section 2. We define the edge xy to be heavy if Rxy ≥ ρ, light if Rxy ≤ Tρ , and medium if T ρ < Rxy < ρ. We define H,M , and L as the set of heavy, medium, and
light edges, respectively. Define TL = ∑ xy∈LRxy . We define TH and TM similarly. Also, recall
that since ∑ xy∈E Rxy = T = TL + TM + TH , it suffices to estimate of these three terms.
Lemma B.2. Let A be an edge set such that for each edge xy ∈ A, Rxy ≤ Tc , for some parameter c, and let S be a subset of A such that every element in A is included in S with probability p = 1τ for τ = 2 · c/α, so that 1/τ = α −2 1c independently, for a sufficient large constant α. Then, with probability at least 9/10, we have
τ ∑ xy∈S Rxy = ∑ xy∈A Rxy ± T
Algorithm 1 Counting Triangles in the Adjacency List Model 1: Input: Adjacency list edge stream and an oracle O that outputs HEAVY if Rxy ≥ T/ρ and
LIGHT otherwise. 2: Output: An estimate of the triangle count T . 3: Initialize Al, Am, Ah = 0, SL, SM , Saux = ∅ 4: if T ≥ (m/ )1/2 then 5: Set ρ = (mT )1/3, p1 = α −2/ρ, p2 = min(β −2ρ/T, 1), p3 = γ −2 log n/ρ. 6: else 7: Set ρ = m1/2/ , p1 = 0, p2 = 1, p3 = γ −2/ρ. {α, β, and γ are large enough constants.} 8: while seeing edges adjacent to v do 9: for all ab ∈ SL ∪ SM do
10: if a, b ∈ N(v) then Cab = Cab + 1. {Update the counter for all the sampled light and medium edges} 11: for all av ∈ Saux do 12: Bav = 1 {seen av twice}. 13: for each incident edge vu do 14: W.p. p3: Saux = {vu} ∪ Saux, Bvu = 0 15: if O(uv) outputs LIGHT then 16: if uv ∈ SL then Al = Al + Cuv . {Finished counting Ruv} 17: else w.p. p1, SL = {vu} ∪ SL 18: else {uv is either MEDIUM or HEAVY} 19: # := |{z : uz ∈ Saux, Buz = 1, z ∈ N(v)}| . 20: if # ≥ p3ρ then {uv is HEAVY} 21: Ah = Ah + # . 22: else if uv ∈ SM then 23: Am = Am + Cuv . {Finished counting Ruv} 24: else 24: With probability p2, SM = {vu} ∪ SM . 25: return: Al/p1 +Am/p2 +Ah/p3.
Proof. We let Y = τ ∑ i∈S Ri = τ ∑ i∈A fiRi, where fi = 1 when i ∈ S and fi = 0 otherwise. It follows that E[Y ] = TA. Then,
Var[Y ] = E[Y 2]− E[Y ]2
= τ2 E[∑ i∈A fiR 2 i + ∑ i 6=j fifjRiRj ] − T 2L ≤ τ2
E[∑ i∈A fiR 2 i ] + ∑ i,j 1 τ2 RiRj − T 2L = τ
∑ i∈A R2i .
To bound this, we notice that Ri ≤ Tc and ∑ iRi = TA ≤ T , so
τ ∑ i∈A R2i ≤ τ ·max i∈A Ri · ∑ i∈A Ri ≤ τ · T c · T = τ c T 2 = 1 α 2T 2 .
By Chebyshev’s inequality, we have that
Pr[|Y − TA| > T ] ≤ 1 α 2T 2 2T 2 ≤ 1 α .
The following lemma shows that for the heavy edges, we can use the edges we have sampled to recognize and estimate them.
Lemma B.3. Let xy be an edge in E. Assume we sample the edges with rate p3 = β −2 log n/ρ in the stream for a sufficiently large constant β, and consider the set
# = |xz has been sampled : {x, y, z} ∈ ∆ and x <s z <s y| . Then we have the following: if Rxy ≥ ρ2 , with probability at least 1 − 1 n5 , we have p −1 3 · # = (1± )Rxy . If Rxy < ρ2 , with probability at least 1− 1 n5 , we have p −1 3 ·# < ρ.
Proof. We first consider the case when Rxy ≥ ρ2 . For each edge i ∈ |xz : {x, y, z} ∈ ∆ and x <s z <s y|, let Xi = 1 if i has been sampled, or Xi = 0 otherwise. We can see the Xi are i.i.d. Bernoulli random variables and E[Xi] = p3. By a Chernoff bound we have
Pr [ | ∑ i Xi − p3Rxy| ≥ p3 ·Rxy ] ≤ 2 exp ( − 2p3 ·Rxy/3 ) ≤ 1 n5 .
Therefore, we have
Pr [ |p−13 ·#−Rxy| ≥ Rxy ] =Pr [ |p−13 · ∑ i Xi −Rxy| ≥ Rxy ] ≤ 1 n5 .
Alternatively, when Rxy < ρ2 , we have
Pr [ |p−13 ·#−Rxy| ≥ 1
2 ρ ] ≤ 1 n5 ,
which means p−13 ·# < ρ with probability at least 1− 1n5 .
We are now ready to prove Theorem 1.1, restated here for the sake of convenience. Theorem 1.1. There exists a one-pass algorithm, Algorithm 1, with space complexity3 Õ(min( −2m2/3/T 1/3, −1m1/2)) in the adjacency list model that, using a learning-based oracle, returns a (1± )-approximation to the number T of triangles with probability at least4 7/10.
Proof. We first consider the case when T ≥ (m/ )1/2. For each edge xy ∈ H , from Lemma B.3 we have that with probability at least 1 − 1n5 , #/p3 = (1± )Rxy in Algorithm 1. If xy /∈ H , then with probability 1− 1n5 , xy will not contribute to Ah. Taking a union bound, we have that with probability at least 1− 1/n3,
Ah/p3 = (1± ) ∑ xy∈H Rxy = (1± )TH .
We now turn to deal with the light and medium edges. For a light edge xy, it satisfies Rxy ≤ T/ρ and therefore we can invoke Lemma B.2 with the parameter c set to ρ. For a medium edge xy, it satisfies Rxy ≤ ρ = T/(T/ρ), and therefore we can invoke Lemma B.2 with the parameter c set to T/ρ. Hence, we have that with probability 4/5,
Am/p2 = TM ± T,Al/p1 = TL ± T . Putting everything together, we have that with probability 7/10,
|Ah/p3 +Am/p2 +Al/p1 − T | ≤ 3 T. Now we analyze the space complexity. We note that there are at most ρ medium edges. Hence, the expected total space we use is O(mp3 + ρp2 +mp1) = O( −2m2/3/T 1/3 log n)5.
When T < (m/ )1/2, as described in Section 2, we only have two classes of edges: heavy and light. We will save all the heavy edges and use sub-sampling to estimate TL. The analysis is almost the same.
3We use Õ(f) to denote O(f · polylog(f)). 4For all of our algorithms, the success probability can be replaced by 1 − δ by running log(1/δ) copies of the algorithm and taking the median. 5Using Markov’s inequality, we have that with probability at least 9/10, the total space we use is less than 10 times the expected total space.

heading: B.1 NOISY ORACLES FOR THE ADJACENCY LIST MODEL
text: Proof of Theorem 1.4. We first consider the case that T < (m/ )1/2. Recall that at this time, our algorithms becomes that we save all the heavy edges xy such that p(e) ≥ T/ √ m and sampling the light edges with rate pl = −1/ √ m. We define L as the set of deemed light edges, H as the set of
deemed heavy edges and L = |L|, H = |H|. Let ρ = T/ √ m, then we have the condition that for every edge e,
1−K · ρ Re ≤ Pr[Oρ(e) = HEAVY] ≤ K · Re ρ .
We will show that, (i) E[H] ≤ (K + 1) √ m , (ii) Var[AL/p1] ≤ (4K + 2)
2T 2. Under the above conditions we can get that with probability at least 9/10 we can get a (1±O( √ K)· )-approximation of T by Chebyshev’s inequality.
For (i), we divide H = Hh ∪ Hl, where the edges in Hh are indeed heavyedges, and the edges in Hl are indeed lightedges. Then, it is easy to see that |Hh| ≤ T/ρ. For every light edges, the probability that it is included in Hl is at most K · Reρ , hence we have
E[|Hh|] ≤ K · ∑ e∈H ( Re ρ ) ≤ K · T ρ = K √ m
which implies E[H] ≤ (K + 1) √ m .
For (ii), we also divide L = Ll ∪ Lh similarly. Then we have Var[AL] ≤ 2(Var[X] + Var[Y ]), where X = ∑ e∈Ll,e has been sampled Re, Y = ∑ e∈Lh,e has been sampled Re. Similar to the proof in Lemma B.2, we have
Var[X] ≤ p1 ∑ e∈L R2e ≤ p1 T ρ ρ2 = p1Tρ.
Now we bound Var[Y ]. For every heavy edge we have that Pr[e ∈ Lh] ≤ K · ρRe . Then, condition on the oracle Oρ, we have
E[Var[Y |Oρ]] ≤ p1K ∑ e∈H ρ Re R2e ≤ p1K ∑ e∈H ρRe ≤ p1KρT .
Also, we have Var[E[Y |Oρ]] < p1K ∑ e∈H ρ Re R2e ≤ p1KρT .
From Var[Y ] = E[Var[Y |Oρ]] + Var[E[Y |Oρ]] we know Var[Y ] ≤ 2p1KρT , which means Var[Al/p1] ≤ 1p1 (4K + 2)ρT = (4K + 2) 2T 2.
When T ≥ (m/ )1/2, recall that the oracle Oρ only needs to predict the edges that are medium edges or light edges. So, we can use the same way to bound the expected space for the deemed medium edges and the variance of the deemed light edges.

heading: B.2 A VALUE PREDICTION ORACLE FOR THE ADJACENCY LIST MODEL
text: In this section, we consider two types of value-prediction oracles, and variants of Algorithm 1 that take advantage of these oracles. Recall that given an edge xy, Rxy = |z : {x, y, z} ∈ ∆ and x <s z <s y| . Definition B.4. A value-prediction oracle with parameter (α, β) is an oracle that, for any edge e, outputs a value p(e) for which E[p(e)] ≤ αRe + β, and Pr[p(e) < Reλ − β] ≤ Ke
−λ for some constant K and any λ ≥ 1.
Our algorithm is based on the following stability property of exponential random variables (see e.g. Andoni (2017)) Lemma B.5. Let x1, x2, ..., xn > 0 be real numbers, and let u1, u2, ...un be i.i.d. standard exponential random variables with parameter λ = 1. Then we have that the random variable max(x1u1 , ..., xn un ) ∼ xu , where x = ∑ i xi and u ∼ Exp(1).
Lemma B.6. Let r = O(ln(1/δ)/ 2) and ≤ 1/3. If we take r independent samplesX1, X2, ..., Xr from Exp(1) and let X = median(X1, X2, ..., Xr), then with probability 1 − δ, X ∈ [ln 2(1 − ), ln 2(1 + 5 )].
Proof. We first prove the following statement: with probability 1 − δ, F (X) ∈ [1/2 − , 1/2 + ], where F is the cumulative density function of a standard exponential random variable.
Consider the case when F (X) ≤ 1/2 − . We use the indicator variable Zi where Zi = 1 if F (Xi) ≤ 1/2 − or Zi = 0 otherwise. Notice that when F (X) ≤ 1/2 − , at least half of the Zi are 1, so Z = ∑ i Zi ≥ r/2. On the other hand, we have E[Z] = r/2 − r , by a Chernoff bound. We thus have Pr[|Z − E[Z]| ≥ r] ≤ 2e−
2r/3 ≤ δ/2 . Therefore, we have with probability at most δ/2, F (X) ≤ 1/2 − . Similarly, we have that with probability at most δ/2, F (X) ≥ 1/2 + . Taking a union bound, we have that with probability at least 1− δ, F (X) ∈ [1/2− , 1/2 + ]. Now, condition on F (X) ∈ [1/2− , 1/2 + ]. Note that F−1(x) = − ln(1− x), so if we consider the two endpoints of F (X), we have
F−1(1/2− ) = − ln(1/2 + ) ≥ (1− ) ln 2,
and F−1(1/2 + ) = − ln(1/2− ) ≤ (1 + 5 ) ln 2.
which indicates that X ∈ [ln 2(1− ), ln 2(1 + 5 )].
The algorithm utilizing this oracle is shown in Algorithm 2. As described in Section 2, here we runs O( 1 2 ) copies of the subroutine and takes a medium of them. For each subroutine, we aim to output the maximum value maxeRe/ue. We will show that with high probability for each subroutine, this maximum will be at least T/ log(K/ ). Hence, we only need to save the edge e, such that (Re + β)/ue is larger than T/ log(K/ ). However, one issue here is we need the information of T . We can remove this assumption when β = 0 using the following way: we will show that with high probability, the total number of edges we save is less than H = O( 1 2 log
2(K/ )(α + mβ/T )), so every time when a new edge comes, we can search the minimum valueM such that the total number of edges e that in at least one subroutine (p(e) + β)/ue > M is less than H(we count an edge multiple times if it occurs in multiple subroutines), then use M as the threshold. We can see M will increase as the new edge arriving and it will be always less than H .
We are now ready to prove Theorem 1.5. We first recall the theorem.
Theorem 1.5. Given an oracle with parameters (α, β), there exists a one-pass algorithm, Algorithm 2, with space complexity O( −2 log2(K/ )(α + mβ/T )) in the adjacency list model that returns a (1± )-approximation to the number of triangles T with probability at least 7/10.
Proof. It is easy to see that for the i-th subroutine, the value f(i) = maxeRe/uie is the sample from the distribution T/u, where u ∼ Exp(1). And if the edge ei, for which the true value Rei/uiei is the maximum value among E, is included in Si, then the output of the i-th subroutine will be a sample from T/u. Intuitively, the prediction value p(e) will help us find this edge.
We will first show that with probability at least 9/10 the following events will happen:
• (i) f(i) ≥ c1T/ log(1/ ) for all i, where c1 is a constant.
• (ii) Let si be the number of the edge e in the i-th subroutine such that (p(e) + β)/uie ≥ c21T/ log 2(K/ ), then ∑ i si ≤ c2( 1 2 log 2(K/ )(α+mβ/T )) for some constant c2.
• (iii) p(ei) + β ≥ c1f(i)/ log(K/ ) for all i.
For (i), recall that f(i) ∼ T/u, where u ∼ Exp(1). Hence, we have
Pr[f(i) < c1T/ log(1/ )] = e − log(1/ )/c1 ≤ 1
100c
1
2 .
Algorithm 2 Counting Triangles in the Adjacency List Model with a Value Prediction Oracle 1: Input: Adjacency list edge stream and an value prediction oracle with parameter(α, β). 2: Output: An estimate of the number T of triangles. 3: Initialize X ← ∅ and H = O( 1 2 log
2(K/ )(α+mβ/T )), and let c be some large constant. 4: for i = 0 to c −2 do {Initialize sets for c −2 copies of samples, where Si stores edges,Qi stores
all the exponential random variables for each sampled edge, andAi stores the current maximum of each sample}
5: Si ← ∅, Qi ← ∅, and Ai ← 0 . 6: while seeing edges adjacent to y in the stream do 7: for i = 0 to c −2 do {Update the counters for each sample} 8: For all ab ∈ Si: if a, b ∈ N(y) then Ciab ← Ciab + 1 9: for each incident edge yx do
10: for i = 0 to c −2 do 11: if xy ∈ Si then {Finished counting Cxy , update the current maximum} 12: Ai ← max(Ai, Cixy/uixy) . 13: else {Put yx into the sample sets temporarily} 14: Let R̂yx be the predicted value of Ryx. 15: R̂yx ← R̂yx + β. 16: Generate uiyx ∼ Exp(1). Set Qi ← Qi ∪ {uiyx}, Si ← Si ∪ {yx}. 17: Set M to be the minimal integer such that ∑ i si ≤ H , where si = |{e ∈ E | R̂e/uie ≥M}|.
18: for i = 0 to c −2 do {Adjust the samples to be within the space limit} 19: Let Qi ← Qi \ {uiab}, Si ← Si \ {ab} if R̂ab/uiab < M for all ab ∈ E. 20: for i = 0 to c −2 do 21: X ← X ∪ {Ai} 22: return: ln 2 ·median(X) .
Taking an union bound we get that with probability at least 99/100, (i) will happen. For each edge e, we have
Pr[p(e) + β < Re/λ] < Ke −λ,
similarly we can get that with probability at least 99/100, (iii) will happen.
For (ii), we first bound the expectation of si. For each edge e, we have Pr [ (p(e) + β)/uie ≥ c21T/ log 2(K/ ) ] = Pr[ue ≤ c21(p(e) + β) log 2(K/ )/T ]
≤ c21(p(e) + β) log 2(K/ )/T
≤ c21(αRe + 2β) log 2(K/ )/T .
Hence, we have
E[si] = ∑ e c21 (αRe + 2β) log 2(K/ ) T = O(log2(K/ )(α+mβ/T )).
Using Markov’s inequality, we get that with probability at least 99/100, (ii) will happen. Finally, taking a union bound, we can get with probability at least 9/10, all the three events will happen.
Now, conditioned on the above three events, we will show that all the subroutine i will output f(i). For the subroutine i, from (ii) we know that M will be always smaller than O(T/ log2(K/ )), and from (i) and (iii) we get that (p(ei) + β)/uiei ≥ Ω(T/ log
2(K/ )). Hence, the edge ei will be saved in the subroutine i. From Lemma B.6 we get that with probability at least 7/10, we can finally get a (1± )-approximation of T .
We note that when β = 0, the space complexity will become O( 1 2 log 2(K/ )α), and in this case we will not need a lower bound of T .
We will also consider the following noise model.
Definition B.7. A value-prediction oracle with parameter (α, β) is an oracle that, for any edge e, outputs a value p(e) for which Pr[p(e) > λαRe+β] ≤ Kλ , and Pr[p(e) < Re λ −β] ≤ K λ for some constant K and any λ ≥ 1.
The algorithm for this oracle is shown in Algorithm 3.
Algorithm 3 Counting Triangles in the Adjacency List Model with a Value Prediction Oracle 1: Input: Adjacency list edge stream and an value prediction oracle with parameter(α, β). 2: Output: An estimate of the number T of triangles. 3: Initialize Sji ← ∅ and A j i ← 0 where i = O(log n) and j = O(log log n). p0 = c −22iβ/T
and pi = c −22iβ(log n)2/T for some constant c. Define I0 = [0, 2β) and Ii = [2iβ, 2i+1β), H ← 0.
4: while seeing edges adjacent to y in the stream do 5: For all ab ∈ Sji : if a, b ∈ N(y) then Cab ← Cab + 1 6: for each incident edge yx do 7: if xy ∈ Sji then 8: Aji ← A j i + Cyx .
9: else 10: Let R̂yx be the predicted value of Ryx. 11: Search i such that (R̂yx + β) ∈ Ii 12: For each j let Sji ← S j i ∪ {yx} with probability pi. 13: for i = 0 to O(log n) do 14: H ← H + median(Aji )/pi 15: return: H .
We now state our theorem.
Theorem B.1. Given an oracle with parameter (α, β), there exists a one-pass algorithm, Algorithm 3, with space complexity O(K 2 ( α(log n)3 log log n+mβ/T ) ) in the adjacency list model that returns a (1± √ K· )-approximation to T with probability at least 7/10.
Proof. Define q(e) = p(e) + β, it is easy to see that from the condition we can get that
Pr[q(e) > 2λαRe] ≤ K 1
λ when Re > 2β,Pr
[ q(e) <
Re λ
] ≤ K 1
λ
We define the set Ei such that e ∈ Ei if and only if q(e) ∈ Ii. We can see E[Ai/pi] = ∑ e∈Ei Re. Now, we bound Var[Ai/pi] when i ≥ 1. LetX = ∑ e∈Ei,Re≤2i+1β Re and Y = ∑ e∈Ei,Re>2i+1β Re, then we have Var[Ai] ≤ 2(Var[X]+ Var[Y ]).
Similar to the proof in Lemma B.2, we can get that
Var[X] ≤ pi ∑
e∈Ei,Re≤2i+1β
R2e ≤ pi(2i+1β)2 T
2i+1β = pi2
i+1βT.
For Var[Y ], recall that for an edge e such that Re ≥ 2i+1β, we have Pr[e ∈ Ei] ≤ K q(e)Re ≤ K 2
i+1β Re . Then, condition on the oracle Oθ, we have
E[Var[Y |Oθ]] ≤ pi ∑
Re≥2i+1β
K 2i+1β
Re R2e = piK2
i+1β ∑
Re≥2i+1β
Re = piK2 i+1βT.
And
Var[E[Y |Oθ]] < pi ∑
Re≥2i+1β
K 2i+1β
Re R2e = piK2 i+1βT.
From Var[Y ] = E[Var[Y |Oθ]] +Var[E[Y |Oθ]] we get that Var[Y ] ≤ 2piK2i+1βT , from which we can get that Var[Ai/pi] = 1p2i Var[Ai] = O(K( / log n) 2T 2). Using Chebyshev’s inequality and taking a median over O(log log n) independent trials, we can get Xi = median(A j i ) satisfies
|Xi − ∑ e∈Ei Re| ≤ √ K( / log n)T with probability 1 − O(1/ log n). A similar argument also holds for I0, which means that after taking a union bound, with probability 9/10, the output of the algorithm 3 is a (1± √ K· )- approximation of T .
Now we analyze the space complexity of Algorithm 3.
For i ≥ 1, we have
E [|Ei|] = E  ∑ Re≤2i−1β/α [e ∈ Ei] + ∑ Re>2i−1β/α [e ∈ Ei]  ≤ E  ∑ Re≤2i−1β/α [e ∈ Ei] + Tα 2i−1β
≤ ∑
Re≤2i−1β/α
2K Re p(e) + Tα 2i−1β ≤ ∑ Re≤2i−1β/α K Re 2i−1β + Tα 2i−1β ≤ (K + 1) Tα 2i−1β ,
and |E0| ≤ m, hence we have that the total expectation of the space is ∑ i piE[|Ei|] =
O(K 2 ( α(log n)3 log log n+mβ/T ) ).

heading: C OMITTED PROOFS FROM SECTION 3
text: We first present Algorithm 4, and then continue to prove Theorem 1.2. In the following algorithm, for two sets A,B of edges, we let wA,B represent the set of pairs of edges (u, v), where u ∈ A, v ∈ B, and u, v share a common vertex.
Algorithm 4 Counting Triangles in the Arbitrary Order Model 1: Input: Arbitrary order edge stream and an oracleOρ that outputs HEAVY ifNxy > ρ and LIGHT
otherwise. 2: Output: An estimate of the triangle count T . 3: Initialize ρ = max { T√ m , 1 } , p = C max { 1 √ T , ρ 2·T } for a constant C. 4: Initialize `1, `2, `3 = 0, and SL, H = ∅. 5: for every arriving edge e in the stream do 6: if the oracle Oρ outputs HEAVY then 7: Add e to H 8: else 9: Add e to SL with probability p.
10: for each w ∈ wSL,SL do 11: if (e, w) is a triangle then 12: Increment `1 = `1 + 1. 13: for each w ∈ wSL,H do 14: if (e, w) is a triangle then 15: Increment `2 = `2 + 1. 16: for each w ∈ wH,H do 17: if (e, w) is a triangle then 18: Increment `3 = `3 + 1. 19: return: ` = `1/p2 + `2/p+ `3.

heading: C.1 PROOF OF THEOREM 1.2
text: Recall that we first assume that Algorithm 4 is given access to a perfect oracle Oρ. That is, for every edge e ∈ E,
Oρ(e) = { LIGHT if Te ≤ ρ HEAVY if Te > ρ,
where Te as the number of triangles incident to the edge e.
Theorem 1.2. First, we assume that T ≥ −2. If not, our algorithm can just store all of the edges, since m ≤ −1 ·m/ √ T .
For each integer i ≥ 1, let E(i) denote the set of edges that are part of exactly i triangles, and let Ei = |E(i)|. Since each triangle has 3 edges, we have that ∑ i≥1 i · E(i) = 3T.
Let T1 denote the set of triangles whose first two edges in the stream are light (according to Oρ). For every triangle ti in T1, let χi denote the indicator of the event that the first two edges of ti are sampled to SL, and let `1 = ∑ i χi. Since each χi is 1 with probability p
2, Ex[χi] = p2, and Var[χi] = p2−p4 ≤ p2. For any two variables χi, χj , they must be uncorrelated unless the triangles ti, tj share a light edge that is among the first two edges of ti and among the first two edges of tj . Moreover, in this case, Cov[χi, χj ] ≤ Ex[χiχj ] = P(χi = χj = 1). This event only happens if the first two edges of both ti and tj are sampled in SL, but due to the shared edge, this comprises 3 edges in total, so P(χi = χj = 1) = p3. Hence, if we define t12i as the first two edges of ti in the stream for each triangle ti, Ex[`1] = p2|T1|, and
Var[`1] ≤ ∑ ti∈T1 p2 + ∑
ti,tj∈T1 t12i ∩t 12 j 6=∅
p3 ≤ p2|T1|+ p3 ∑ Te≤ρ T 2e
= p2|T1|+ p3 · ρ∑ t=1 t2 · E(t) ≤ (p2 + 3p3 · ρ) · T .
The first line follows by adding the covariance terms; the second line follows since each light edge e has at most T 2e pairs (ti, tj) intersecting at e; the third line follows by summing over t = Te, ranging from 1 to ρ, instead over e; and the last line follows since ∑ t≥1 t · E(t) = 3T .
Now, let T2 denote the set of triangles whose first two edges in the stream are light and heavy (in either order). For every triangle t = (e1, e2, e3) in T2, e1, e2 are sampled to SL∪H with probability p. Also all other triangles have no chance to contribute to `2. Hence, Ex[`2] = p · T2. Also, two triangles ti, tj ∈ T2 that intersect on an edge e have Cov(χi, χj) 6= 0 only if e is light and e ∈ t12i , t12j . In this case. Cov(χi, χj) ≤ Ex[χiχj ] ≤ p, since if e is added to SL (which happens with probability p) then χi = χj = 1 as the other edges in t12i , t 12 j are heavy and are added to H with probability 1. Therefore,
Var[`2] = ∑ ti∈T2 p+ ∑
ti,tj∈T2 t12i ∩t 12 j =e, Oρ(e)=LIGHT
p ≤ (p+ 3p · ρ) · T,
by the same calculations as was done to compute Var[`1].
Finally, let T3 denote the set of triangles whose first two edges in the stream are heavy. Then `3 = |T3|. Now, using the well known fact that Var[X+Y ] ≤ 2(Var[X]+Var[Y ]) for any (possibly correlated) random variables X,Y, we have that
Var[p−2`1 + p−1`2 + `3] ≤ 2 ( p−4(p2 + 3p3ρ)T + p−2(p+ 3pρ)T ) ≤ 4T (p−2 + 3p−1ρ),
since `3 has no variance. Moreover, Ex[p−2`1 + p−1`2 + `3] = |T1| + |T2| + |T3| = T . So, by Chebyshev’s inequality, since ` = `1/p2 + `2/p+ `3,
Pr[|`− T | > T ] < Var[`] 2 · T 2 < 4(p−2 + 3p−1ρ) 2 · T .
Therefore, setting p = C · max { 1/( · √ T ), ρ/( 2 · T ) } for some fixed constant C implies that,
with probability at least 2/3, ` is a (1± )-multiplicative estimate of T .
Furthermore, the expected space complexity is O(mp + H) = O(mp + T/ρ). Setting ρ = max{ T/ √ m, 1} implies that the space complexity isO( −1m/ √ T+ −2m/T+ −1 √ m ·T/T ) = O( −1m/ √ T + −1 √ m · T/T ), since we are assuming that T ≥ −2. Hence, assuming that T is a constant factor approximation of T , the space complexity is O( −1m/ √ T + −1 √ m).

heading: C.2 PROOF OF THEOREM 1.2 FOR THE K-NOISY ORACLE
text: In this section, we prove Theorem 1.2 for the case that the given oracle is a K-noisy oracle, as defined in Definition 1.1. That is, we prove the following:
Theorem C.1. Suppose that the oracle in Algorithm 4 is a K-noisy oracle as defined in Definition 1.1 for a fixed constant K. Then with probability 2/3, Algorithm 4 returns ` ∈ (1 ± )T , and uses space at most O ( −1 ( m/ √ T + √ m )) .
Recall that in Definition 1.1, we defined a K-noisy oracle if the following holds. For every edge e, 1−K · ρNe ≤ Pr[Oρ(e) = HEAVY] ≤ K · Ne ρ . We first visualize this model. To visualize this error
model, in Figure 4 we have plotted Ne versus the range [ 1−K · ρNe ,K · Ne ρ ] for K = 2. We set Ne to vary on a logarithmic scale for clarity. For example, if Ne exceeds the threshold ρ by a factor of 2, there is no restriction on the oracle output, whereas if Ne exceeds ρ by a factor of 4, then the oracle must classify the edge as heavy with probability at least 0.5. In contrast, the blue piece-wise line shows the probability Pr[Oρ(e) = HEAVY] if the oracle Oρ is a perfect oracle.
Proof of Theorem C.1. We follow the proof of Theorem 4.1 from the main paper. Let T1 be the set of triangles such that their first two edges in the stream are light according to the oracle. Let T2 be the set of triangles such that their first two edges in the stream are determined light and heavy according to the oracle. Finally, let T3 be the set of triangles for which their first two edges are determined heavy by the oracle. Furthermore, we define χi for each triangle ti, t(e) for each edge e, and E(i), Ei for each i ≥ 1 as done in Theorem 4.1. Finally, we define L(i) as the set of deemed light edges that are part of exactly i triangles, and L(i) = |L(i)|. First, note that the expectation (over the randomness of Oρ) of L(i) is at most E(i) · K · ρi , since our assumption on Pr[Oρ(e) = heavy] tells us that Pr[Oρ(e) = light] ≤ K · ρi if t(e) = i. Therefore, by the same computation as in Theorem 4.1, we have that, conditioning on the oracle,
Ex[`1|Oρ] = p2|T1] and
Var[`1|Oρ] = ∑ ti∈T1 p2 + ∑
ti,tj∈T1 t12i ∩t 12 j 6=∅
p3
≤ p2|T1|+ p3 ∑ e light t(e)2
= p2|T1|+ p3 · ∑ t≥1 t2 · L(t)
But since ExOρ [L(t)] ≤ K·ρ t · E(t) for all t, we have that ExOρ [Var[`1|Oρ]] ≤ ExOρ [ p2 · |T1|+ p3 · ∑ t≥1 t2L(t) ] = p2|T1|+Kρ · p3
∑ t≥1 t · E(t)
≤ (p2 + 3Kp3 · ρ) · T.
A similar analysis to the above shows that Ex[`2] = p · |T2| and that ExOρ [Var[`2|Oρ]] ≤ ExOρ [ p · |T2|+ p · ∑ t≥1 t2L(t) ] = p|T2|+Kρ · p
∑ t≥1 t · E(t)
≤ (p+ 3Kp · ρ) · T.
Hence, as in Theorem 4.1, we have Ex[`|Oρ] = T and ExOρ [Var[`|Oρ]] ≤ 4T · (p−2 + 3Kp−1ρ). Thus, Ex[`] = Ex[Ex[`|Oρ]] = T and Var[`] = ExOρ [Var[`|Oρ]]+VarOρ [Ex[`|Oρ]] ≤ 4T ·(p−2 + 3Kp−1ρ) by the laws of total expectation/variance. Therefore, since K is a constant, the variance is the same as in Theorem 4.1, up to a constant. Therefore, we still have that ` ∈ (1± O( )) · T with probability at least 2/3.
Finally, the expected space complexity is bounded by mp+ ∑ e∈m Pr[Oρ(e) = heavy] ≤ mp+ ∑ t≥1 E(t) ·K · t ρ
= mp+ K ρ · ∑ t≥1 E(t) · t
= O(mp+ T/ρ), since ∑ t≥1E(t) · t = 3T and K = O(1). Hence, setting ρ and p as in the proof of Theorem 4.1 implies that the returned value is a (1 ± )-approximation of T , and the the space complexity is O( −1(m/ √ T + √ m)) as before.

heading: C.3 LOWER BOUND
text: In this section, we prove a lower bound for algorithms in the arbitrary order model that have access to a perfect heavy edge oracle. Here heavy means Nuv ≥ T/c for a pre-determined threshold c, and we assume c = o(m) and T/c > 1, as otherwise the threshold will be too small or too close to the average to give an accurate prediction. The following theorem shows an Ω(min(m/ √ T ,m3/2/T )) lower bound even with such an oracle. Theorem C.2. Suppose that the threshold of the oracle c = O(mq), where 0 ≤ q < 1. Then for any T and m, T ≤ m, there exists m′ = Θ(m) and T ′ = Θ(T ) such that any one-pass arbitrary order streaming algorithm that distinguishes between m′ edge graphs with 0 and T ′ triangles
with probability at least 2/3 requires Ω(m/ √ T ) space. For any T and m, T = Ω(m1+δ) where max(0, q − 12 ) ≤ δ < 1 2 , there exists m
′ = Θ(m) and T ′ = Θ(T ) such that any one-pass arbitrary order streaming algorithm that distinguishes between m′ edge graphs with 0 and T ′ triangles with probability at least 2/3 requires Ω(m3/2/T ) space.
When T ≤ m, we consider the hubs graph mentioned in Kallaugher & Price (2017). Definition C.3 (Hubs Graph, Kallaugher & Price (2017)). The hubs graph Hr,d consists of a single vertex v with 2rd incident edges, and d edges connecting disjoint pairs of v’s neighbors to form triangles.
It is easy to see that in Hr,d, each edge has at most one triangle. Hence, there will not be any heavy edges of this kind in the graph. In Kallaugher & Price (2017), the authors show an Ω(r √ d) lower bound for the hubs graph. Lemma C.4 (Kallaugher & Price (2017)). Given r and d, there exist two distributions G1,G2 on subgraphs G1 and G2 of Hr,d, such that any algorithm which distinguishes them with probability at least 2/3 requires Ω(r √ d) space, where Gi has Θ(rd) edges and T (G1) = d, T (G2) = 0.
Now, given T and m, where T ≤ m, we let r = Θ(m/T ) and d = T . We can see Hr,d has Θ(m) edges and T triangles, and we need Ω(r √ d) = Ω(m/ √ T ) space.
When T > m, we consider the following Ω(m3/2/T ) lower bound in Bera & Chakrabarti (2017).
Let H be a complete bipartite graph with b vertices on each side (we denote the two sides of vertices by A and B). We add an additional N vertex blocks V1, V2, ...VN with each |Vi| = d. Alice has an N -dimensional binary vector x. Bob has an N -dimensional binary vector y. Both x and y have exactly N/3 coordinates that are equal to 1. Then, we define the edge sets
EAlice = ⋃
i:xi=1
{{u, v}, u ∈ A, v ∈ Vi}
and EBob = ⋃ i:yi=1 {{u, v}, u ∈ B, v ∈ Vi} .
Let the final resulting graph be denoted by G = (V,E) where V = VH ∪ V1 ∪ ... ∪ VN and E = EH ∪ EAlice ∪ EBob.
In Bera & Chakrabarti (2017), the authors show by a reduction to the DISJN/3N problem in communication complexity, that we need Ω(N) space to distinguish the case when G has 0 triangles from the case when G has at least b2d triangles.
Given m and T , T = Θ(m1+δ) where 1 ≤ δ < 1/2, as shown in Bera & Chakrabarti (2017), we can set b = Ns and d = Ns−1 where s = 1/(1 − 2δ). This will make m = Θ(N2s) and T = Θ(N3s−1), which will make the Ω(m3/2/T ) lower bound hold. Note that at this time each edge will have an O( 1m )-fraction of triangles or an O( 1
m1− 1 2s
)-fraction of triangles. Assume the
threshold of the oracle c = O(mq). When δ ≥ max(0, q − 12 ), there will be no heavy edges in the graph.
Theorem C.2 follows from the above discussion.

heading: D FOUR-CYCLE COUNTING IN THE ARBITRARY ORDER MODEL
text: In the 4-cycle counting problem, for each xy ∈ E(G), define Nxy = |z, w : {x, y, z, w} ∈ | as the number of 4-cycles attached to edge xy.
In this section, we present the one-pass Õ(T 1/3+ −2m/T 1/3) space algorithm behind Theorem 1.3 and the proof of the theorem.6
We begin with the following basic idea.
6We assume 1 T1/6 ≤ O( ), which is the same assumption as in previous work
• Initialize: C ← 0, S ← ∅. On the arrival of edge uv: – With probability p, S ← {uv} ∪ S. – C ← C + |{{w, z} : uw,wz and zv ∈ S}|.
• Return C/p3.
Following the analysis in Vorotnikova (2020), we have
Var[C] ≤ O(Tp3 + T∆Ep5 + T∆W p4) ,
where ∆E and ∆W denote the maximum number of 4-cycles sharing a single edge or a single wedge.
There are two important insights from the analysis: first, this simple sampling scheme can output a good estimate to the number of 4-cycles on graphs that do not have too many heavy edges and heavy wedges (the definitions of heavy will be shown later). Second, assuming that we can store all the heavy edges, then at the end of the stream we can also estimate the number of 4-cycles that have exactly one heavy edge but do not have heavy wedges.
For the 4-cycles that have heavy wedges, we use an idea proposed in McGregor & Vorotnikova (2020); Vorotnikova (2020): for any node pair u and v, if we know their number of common neighbors (denoted by k), we can compute the exact number of 4-cycles with u, v as a diagonal pair (i.e., the four cycle contains two wedges with the endpoints u, v), and this counts to ( k 2 ) . Furthermore, if k is large (in this case we say all the wedges with endpoints u, v are heavy), we can detect it and obtain a good estimation to k by a similar vertex sampling method mentioned in Section 3. We can then estimate the total number of 4-cycles that have heavy wedges with our samples.
At this point, we have not yet estimated the number of 4-cycles having more than one heavy edge but without heavy wedges. However, McGregor & Vorotnikova (2020) shows this class of 4-cycles only takes up a small fraction of T , and hence we can get a (1± )-approximation to T even without counting this class of 4-cycles.
The reader is referred to Algorithm 5 for a detailed version of our one-pass, 4-cycle counting algorithm. Before the stream, we randomly select a node set S, where each vertex is in S with probability p independently, and we later store all edges that are incident to S during the stream. In the meantime, we define the edge uv to be heavy if Nuv ≥ T 2/3 and train the oracle to predict whether uv is heavy or not when we see the edge uv during the stream. Let p = Õ( −2/T 1/3). We store all the heavy edges and sample each light edge with probability p during the stream. Upon seeing see a light edge uv, we look for the 4-cycles that are formed by uv and the light edges that have been sampled before, and then record them in set D. At the end of the stream, we first find all the node pairs that share many common neighbors in S and identify them as heavy wedges. Then, for each 4-cycle d ∈ D, we check if d has heavy wedges, and if so, remove it from D. Finally, for each heavy edge uv indicated by the oracle, we compute the number of 4-cycles that are formed by uv and the sampled light edges, and without heavy wedges. This completes all parts of our estimation procedure.
We now prove Theorem 1.3, restated here for the sake of convenience.
Theorem 1.3. There exists a one-pass algorithm, Algorithm 5, with space complexity Õ(T 1/3 + −2m/T 1/3) in the arbitrary order model that, using a learning-based oracle, returns a (1 ± )- approximation to the number T of four cycles with probability at least 7/10.
Proof. From the Lemma 3 in Vorotnikova (2020), we know that with probability at least 9/10, we can get an estimate Aw such that Aw = Tw ± T. Where Tw is the number of the 4-cycles that have at least one heavy wedge. We note that if a 4- cycle has two heavy wedges, it will be counted twice. However, Vorotnikova (2020) shows that this double counting is at most O(T 2/3) = O( )T .
For the edge sampling algorithm mentioned in D, from the analysis in Vorotnikova (2020), we have
Var[Al/p3] ≤ O(T/p3 + T∆E/p+ T∆W /p2) .
Algorithm 5 Counting 4-cycles in the Arbitrary Order Model 1: Input: Arbitrary Order Stream and an oracle that outputs TRUE if Nxy ≥ T/ρ and FALSE
otherwise. 2: Output: An estimate of the number T of 4-cycles. 3: Initialize Al ← 0, Ah ← 0, Aw ← 0 EL ← ∅ EH ← ∅, ES ← ∅, and W ← ∅. Set ρ← T 1/3, p ← α −2 log n/ρ for a sufficiently large α, and Let S be a random subset of nodes such that each node is in S with probability p. 4: while seeing edge uv in the stream do 5: if u ∈ S or v ∈ S then 6: ES ← {uv} ∪ ES . 7: if the oracle outputs FALSE then 8: With probability p, EL ← {uv} ∪ EL . 9: Find pair (w, z) such that uw,wz, and zv ∈ EL, let D ← D ∪ {(u,w, z, v)} .
10: else 11: EH ← {uv} ∪ EH . 12: for each node pair (u, v) do 13: let q(u, v) be the number of wedges with center in S and endpoints u and v. 14: if q(u, v) ≥ pT 1/3 then 15: Aw ← Aw + ( q(u,v)
2
) .
16: W ←W ∪ {(u, v)} . 17: for each 4-cycle d in D do 18: if the end points of wedges in d are not in W then 19: Al ← Al + 1 20: for each edge uv in EH do 21: for each 4-cycle d formed with uv and e ∈ EL do 22: if the end points of wedges in d are not in W then 23: Ah ← Ah + 1 24: return: Al/p3 +Ah/p3 +Aw .
Notice that in our algorithm, the threshold of the heavy edges and heavy wedges are Nuv ≥ T 2/3 and Nw ≥ T 1/3, respectively, which means Var[Alp3 ] = O(
2T 2). Hence, we can get an estimate Al such that with probability at least 9/10,
Al = Tl ± T , where Tl is the number of 4-cycles that have no heavy edges. Similarly, we have with probability at least 9/10, Ah = Th ± T , where Th is the number of 4-cycles that have at most one heavy edge.
One issue is that the algorithm has not yet estimated the number of 4-cycles having more than one heavy edge, but without heavy wedges. However, from Lemma 5.1 in McGregor & Vorotnikova (2020) we get that the number of this kind of 4-cycles is at most O(T 5/6) = O( )T . Hence putting everything together, we have
|Al/p3 +Ah/p3 +Aw − T | ≤ O( )T , which is what we need.
Now we analyze the space complexity. The expected number of light edges we sample is O(mp) = Õ( −2m/T 1/3) and the expected number of nodes in S and edges in ES is O(2mp) = Õ( −2m/T 1/3). The expected number of 4-cycles we store in D is O(Tp3) = Õ( −6). We store all the heavy edges, and the number of heavy edges is at most O(T 1/3). Therefore, the expected total space is Õ(T 1/3 + −2m/T 1/3).

heading: E RUNTIME ANALYSIS
text: In this section, we verify the runtimes of our Algorithms 1, 2, 3, 4, and 5.
Proposition E.1. Algorithm 1 runs in expected time at most Õ ( min( −2m5/3/T 1/3, −1m3/2) ) in
the setting of Theorem 1.1, or Õ ( min( −2m5/3/T 1/3,K · −1m3/2) ) in the setting of Theorem 1.4.
Proof. For each edge ab ∈ SL ∪ SM , we check whether we see both va and vb (lines 9-10) when looking at edges adjacent to v. So, this takes time |SL|+ |SM | per edge in the stream. We similarly check for each edge in Saux (lines 11-12), so this takes time |Saux|. Finally, for each edge vu (line 13), we note that lines 14-17 can trivially be implemented in O(1) time, along with 1 call to the oracle. The remainder of the oracle simply involves looking through the set Saux and SM to search or count for elements. Thus, the overall runtime is O(|SL|+ |SM |+ |Saux|) per stream element, so the runtime is O (m · (|SL|+ |SM |+ |Saux|)). This is at most O(m · S), where S is the space used by the algorithm. So, the runtime is Õ ( min( −2m5/3/T 1/3, −1m3/2 ) in the setting of Theorem 1.1, and is at most
Õ ( min( −2m5/3/T 1/3,K · −1m3/2) ) in the setting of Theorem 1.4.
Proposition E.2. Algorithm 2 runs in time Õ( −2(α+mβ/T )m).
Proof. For each edge ab ∈ Si for each 0 ≤ i ≤ c −2, we check whether we see both ya and yb in the stream when looking at edges adjacent to y. So, lines 7-8 take time O( ∑ |Si|) for each edge we see in the stream. By storing each Si (and each Qi) in a balanced binary search tree or a similar data structure, we can search for xy ∈ Si in time O(log n) in line 11, and it is clear that lines 12-16 take time O(log n) (since insertion into the data structure for Qi, Si can take time O(log n)). Since we do this for each i from 0 to c −2 and for each incident edge yx we see, in total we spend O( −2 log n + ∑ |Si|) time up to line 16. The remainder of the lines take time O( −2 ·m log n), since the slowest operation is potentially deleting an edge from each Si and a value from each Qi up to m times (for each edge).
Overall, the runtime is Õ( −2 ·m+m · ∑ |Si|) = Õ(m ·S), where S is the total space used by the algorithm. Hence, the runtime is Õ( −2(α+mβ/T )m).
Proposition E.3. Algorithm 3 runs in time Õ(K −2(α+mβ/T )m).
Proof. For each edge ab ∈ Sji for each 1 ≤ i ≤ O(log n), 1 ≤ j ≤ O(log log n), we check whether we see both ya and yb in the stream when looking at edges adjacent to y. So, line 5 takes time O( ∑ |Sji |) for each edge we see in the stream. By storing each S j i in a balanced binary search tree or a similar data structure, we can search for xy ∈ Si in time O(log n) in line 7, and it is clear that lines 8-12 take time O(log n) (since insertion into the data structure for Qji can take time O(log n)). Since we do this for each i from 0 to c −2 and for each incident edge yx we see, in total we spend poly log n ·O( ∑ |Si|) time up to line 12. Finally, lines 13-15 take time poly log n.
Overall, the runtime is Õ(m · ∑ |Si|) = Õ(m ·S), where S is the total space used by the algorithm. Hence, the runtime is Õ(K −2(α+mβ/T )m).
Proposition E.4. Algorithm 4 runs in time Õ ( −1 ·m2/ √ T + −1 ·m3/2 ) .
Proof. For each edge e in the stream, first we check the oracle, and we either add e toH or to SL with probability p (lines 6-9), which takeO(1) time. The remaining lines (lines 10-18) involve operations that take O(1) time for each w which represents a pair (e1, e2) of edges where e1, e2 ∈ SL ∪ H and (e, e1, e2) forms a triangle. So, the runtime is bounded by the amount of time it takes to find all e1, e2 ∈ SL ∪H such that (e, e1, e2) forms a triangle. If the edge e = (u, v), we just find all edges in SL ∪H adjacent to u, and all edges in SL ∪H adjacent to v. Then, we sort these edges based on their other endpoint and match the edges if they form triangles. So, the runtime is Õ(|SL| + |H|) per edge e in the stream. Finally, line 19 takes O(1) time.
Overall, the runtime is Õ(m · (|SL|+ |H|)) = Õ(m ·S) where S is the total space of the algorithm. So, the runtime is Õ ( −1 ·m2/ √ T + −1 ·m3/2 ) .
Proposition E.5. Algorithm 5 runs in time Õ ( −2/T 1/3 · (n3 +m2) ) .
Proof. We note that for each edge uv in the stream (line 4), the code in the loop (lines 5-11) can be implemented using 1 oracle call and Õ(|EL|) time. The only nontrivial step here is to find pairs (w, z) such that uw,wz, zv are all in EL. However, by storing EL in a balanced binary search tree or similar data structure, one can enumerate through each edge wz ∈ EL and determine if uw and zv are in EL in O(log |EL|) time. So, lines 4-11 take time Õ(|EL|) per stream element. Next, lines 12-16 can easily be implemented in time O(n2 · |S|), lines 17-19 can be easily implemented in time Õ(|D|) if the vertices in W are stored properly, and lines 20-23 can be done in Õ(|EH | · |EL|) time. The last part is true since we check each uv ∈ EH and e = (u′, v′) ∈ EL, and then check if u, u′, v′, v form a 4-cycle by determining if u, u′ and v, v′ are in EL ∪EH (which takes time O(log |EL| + log |EH |) time assuming EL, EH are stored in search tree or similar data structure).
Overall, we can bound the runtime as Õ(m·|EL|+n2·|S|+|D|+|EH |·|EL|) = Õ(m·|EL|+n2·|S|). As each edge is in EL with probability at most p and each edge is in S with probability at most p, the total runtime is Õ ( (m2 + n3) · p ) = Õ ( −2/T 1/3 · (n3 +m2) ) .

heading: F ADDITIONAL EXPERIMENTAL RESULTS
text: All of our graph experiments were done on a CPU with i5 2.7 GHz dual core and 8 GB RAM or a CPU with i7 1.9 GHz 8 core and 16GB RAM. The link prediction training was done on a single GPU.

heading: F.1 DATASET DESCRIPTIONS
text: • Oregon: 9 graphs sampled over 3 months representing a communication network of internet routers Leskovec & Krevl (2014); Leskovec et al. (2005).
• CAIDA: 98 graphs sampled approximately weekly over 2 years, representing a communication network of internet routers Leskovec & Krevl (2014); Leskovec et al. (2005).
• Reddit Hyperlinks: Network where nodes represent sub communities (subreddits) and edges represent posts that link two different sub communities Leskovec & Krevl (2014); Kumar et al. (2018).
• WikiBooks: Network representing Wikipedia users and pages, with editing relationships between them Rossi & Ahmed (2015).
• Twitch: A user-user social network of gamers who stream in a certain language. Vertices are the users themselves and the links are mutual friendships between them. Rozemberczki et al. (2019)
• Wikipedia: This is a co-occurrence network of words appearing in the first million bytes of the Wikipedia dump. Mahoney (2011)
• Synthetic Power law: Power law graph sampled from the Chung-Lu-Vu (CLV) model with the expected degree of the ith vertex proportional to 1/i2 Chung et al. (2003). To create this graph, the vertices are ‘revealed’ in order. When the jth vertex arrives, the probability of forming an edge between the jth vertex and ith vertex for i < j is proportional to 1/(ij)2.

heading: F.2 DETAILS ON LINK PREDICTION ORACLE
text: Our oracle for the Twitch and Wikipedia graphs is based on Link Prediction, where the task is to estimate the likelihood of the existence of edges or to find missing links in the network. Here we use the method and code proposed in Zhang & Chen (2018). For each target link, it will extract a local enclosing subgraph around a node pair, and use a Graph Neural Network to learn general graph structure features for link prediction. For the Twitch network, we use all the training links as the training data for the graph neural network, while for the Wikipedia network, we use 30% of the training links as the training data due to memory limitations. For the Twitch network, our set of
links that we will try to predict are between two nodes that have a common neighbor in the training network, but do not form a link in the training network. This is about 3.8 million pairs, and we call this the candidate set. We do this for memory considerations. For the remaining node pairs, we set the probability they form a link to be 0. For the Wikipedia network, we randomly select a link candidate set of size 20 times the number of edges (about 1 million pairs) from the entire set of testing links. These link candidate sets will be used by the oracle to determine heaviness. Then, we use this network to do our prediction for all links in our candidate sets for the two networks.
Now we are ready to build our heavy edge oracle. For the adjacency list model, when we see the edge uv in the stream, we know all the neighbors of u, and hence, we only need to predict the neighbors of v. Let deg(v) be the degree of v in the training graph. The training graph and testing graph are randomly split. Hence, we can use the training set to provide a good estimation to the degree of v. Next, we choose the largest deg(v) edges incident to v from the candidate set, in terms of their predicted likelihood given by the the neural network, as our prediction of N(v), which leads to an estimate of Ruv . For the arbitrary order model, we use the same technique as above to predict N(u) and N(v), and estimate Nuv .

heading: F.3 PARAMETER SELECTION FOR ALGORITHM 2
text: We need to set two parameters for Algorithm 2: p, which is the edge sampling probability, and θ, which is the heaviness threshold. In our theoretical analysis, we assume knowledge of a lower bound on T in order to set p and θ, as is standard in the theoretical streaming literature. However, in practice, such an estimate may not be available; in most cases, the only parameter we are given is a space bound for the number of edges that can be stored. To remedy this discrepancy, we modify our algorithm in experiments as follows.
First, we assume we only have access to the stream, a space parameter Z indicating the maximum number of edges that we are allowed to store, and an estimate of m, the number of edges in the stream. Given Z, we need to designate a portion of it for storing heavy edges, and the rest for storing light edges. The trade-off is that the more heavy edges we store, the smaller our sampling probability of light edges would be. We manage this trade off in our implementation by reserving 0.3 ·Z of the edge ‘slots’ for heavy edges. The constant 0.3 is fixed throughout all our experiments. We then set p = 0.7 · Z/m. To improve the performance of our algorithm, we optimize for space usage by always insuring that we are storing exactly Z space (after observing the first Z edges of the stream). To do so and still maintain our theoretical guarantees, we perform the following procedure. Call the first Z edges of the stream the early phase and the rest of the edges the late phase.
We always keep edges in the early phase to use our space allocation Z and also keep track of the 0.3-fraction of the heaviest edges. After the early phase is over, i.e., more than Z edges have passed in the stream, if a new incoming edge is heavier than the lightest of the stored heavy edges, we replace the least heavy stored edge with the new arriving edge and re-sample the replaced edge with probability p. Otherwise, if the new edge is not heavier than the lightest stored edge, we sample the new incoming edge with probability p. If we exceed Z, the space threshold, we replace one of the light edges sampled in the early phase. Then similarly as before, we re-sample this replaced edge with probability p and continue this procedure until one of the early light edges has been evicted. In the case that there are no longer any of the light edges sampled in the early phase stored, we replace a late light edge and then any arbitrary edge (again performing the re-sampling procedure for the evicted edge).
Note that in our modification, we only require our predictor be able to compare the heaviness between two edges, i.e., we do not need the predictor to output an estimate of the number of triangles on an edge. This potentially allows for more flexibility in the choice of predictors.
If the given space bound meets the space requirements of Theorem C.1, then the theoretical guarantees of this modification simply carry over from Theorem 1.2: we always keep the heaviest edges and always sample light edges with probability at least p. In case the space requirements are not met, the algorithm stores the most heavy edges as to reduce the overall variance.

heading: F.4 ADDITIONAL FIGURES FROM ARBITRARY ORDER TRIANGLE COUNTING EXPERIMENTS
text: Additional figures for our arbitrary order triangle counting experiments are given in Figures 5 and 6.

heading: F.5 EXPERIMENTAL DESIGN FOR ADJACENCY LIST EXPERIMENTS
text: We use the same predictor for Nxy in Section 4 as a prediction for Rxy . The experiment is done under a random vertex arrival order. For the learning-based algorithm, suppose Z is the maximum number of edges that we are allowed to store. we set the k = Z/10 edges with the highest predicted Ruv values to be the heavy edges, and store them during the stream (i.e., we use 10% of the total space for storing the heavy edges). For the remaining edges, we use a similar sampling-based method. Note that it is impossible to know the k-heaviest edges before we see all the edges in the stream. However, in the implementation we can maintain the k heaviest edges we currently have seen so far, and evict the smallest edge in the set when a new heavy edge is predicted by the oracle.
We also consider the multi-layer sub-sampling algorithm mentioned in Section B.2, which uses more information from the oracle. We notice that in many graph datasets, most of the edges having very few number of triangles attached to. Taking an example of the Oregon and CAIDA graph, only about 3%-5% of edges will satisfy Re ≥ 5 under a random vertex arrival order. Hence, for this edges, intuitively we can estimate them using a slightly smaller space.
For the implementation of this algorithm(we call it multi-layer version), we use 10% of the total space for storing the top k = Z/10 edges, and 70% of the space for sub-sampling the edges that the oracle predict value is very tiny(the threshold may be slightly different for different datasets, like for the Oregon and CAIDA graph, we set the threshold to be 5). Then, we use 20% of the space for sub-sampling the remaining edges, for which we call them the medium edges.

heading: F.6 ADDITIONAL FIGURES FROM ADJACENCY LIST TRIANGLE COUNTING EXPERIMENTS
text: Additional figures from the adjacency list triangle counting experiments are shown in Figure 7. They are qualitatively similar to the results presented in Section 4.1 of the main body as the multi-layer sampling algorithm is superior over the MVV baseline for all of our datasets.

heading: F.7 ACCURACY OF THE ORACLE
text: In this section, we evaluate the accuracy of the predictions the oracle gives in our experiments.
Value Prediction Oracle : We use the prediction of Nxy in Section 4 as a value prediction for Rxy(x ≤s y), under a fixed random vertex arrival order. The results are shown in Figure 8. For a fixed approximation factor k, we compute the failure probability δ of the value prediction oracle as follows: δ = #/m, where m is the number of total edges and # equals to the number of edges e that p(e) ≥ kαRe + β or p(e) ≤ 1kRe − β, respectively. Here we set α = 1, β = 10 for all graph datasets.
We can see for the smaller side, there are very few edges e such that p(e) ≤ 1kRe − β. This meets the assumption of the exponential decay tail bound of the error. For the larger side, it also meets the assumption of the linear decay tail bound on most of the graph datasets.

heading: F.8 DETAILS ON ORACLE TRAINING OVERHEAD
text: The overhead of the oracles used in our experiments vary from task to task. For the important use case illustrated by the Oregon and CAIDA datasets in which we are interested in repeatedly counting triangles over many related streams, we can pay a small upfront cost to create the oracle which can be reused over and over again. Thus, the time complexity of building the oracle can be amortized over many problem instances, and the space complexity of the oracle is relatively small as we only need to store the top 10% of heavy edges from the first graph (a similar strategy is used in prior work on learning-augmented algorithms in Hsu et al. (2019b)). To give more details, for this snapshot oracle, we simply calculate the Ne values for all edges only in the first graph. We then keep the heaviest edges to form our oracle. Note that this takes polynomial time to train. The time complexity of using this oracle in the stream is as follows: when an edge in the stream comes, we
simply check if it’s among the predicted heavy edges in our oracle. This is a simple lookup which can even be done in constant time using hashing.
For learning-based oracles like the linear regression predictor, we similarly need to pay an upfront cost to train the model, but the space required to store the trained model depends on the dimension of the edge features. For the Reddit dataset with ∼ 300 features, this means that the storage cost for the oracle is a small fraction of the space of the streaming algorithm. Training of this oracle can be done in polynomial time and can even be computed in a stream via sketching and sampling techniques which reduce the number of constraints from m (number of edges) to roughly linear in the number of features.
Our expected value oracle exploits the fact that our input graph is sampled from the CLV random graph model. Given this, we can explicitly calculate the expected value of Ne for every edge which requires no training time and nearly constant space. For training details for our link prediction model, see Section F.2. Note that in general, there is a wide and rich family of predictors which can be trained using sublinear space or in a stream such as regression Woodruff (2014), classification for example using SVMs Andoni et al. (2020); Rai et al. (2009) and even deep learning modelsGomes et al. (2019).
G IMPLICIT PREDICTOR IN PRIOR WORKS
We prove that the first pass of the two pass triangle counting Algorithm given in Section 3.1 of McGregor et al. (2016), satisfies the conditions of the K-noisy oracle in Definition 1.1. Therefore, our work can be seen as a generalization of their approach when handling multiple related data sets,
where instead of performing two passes on each data set and using the first of which to train the heavy edge oracle, we perform the training once according to the first related dataset, and we get a one pass algorithm for all remaining sets.
We first recall the first pass of (McGregor et al., 2016, Section 3.1):
1. Sample each node z of the graph with probability p = C −2 logm/ρ for some large constant C > 0. Let Z be the set of sampled nodes.
2. Collect all edges incident on the set Z.
3. For any edge e = {u, v}, let t̃(e) = |{z ∈ Z : u, v ∈ N(z)}| and define the oracle as oracle(e) = {
LIGHT if t̃(e) < p · ρ HEAVY if t̃(e) ≥ p · ρ.
Lemma G.1. For any edge e = (u, v), oracle(e) = LIGHT implies Ne ≤ 2ρ and oracle(e) = HEAVY implies Ne > ρ/ √ 2 with failure probability at most 1/n10.
Proof. For any edge e, it follows that t̃(e) ∼ Bin(Ne, p). Therefore if Ne > 2ρ,
Pr[t̃(e) < p · ρ] ≤ exp(−Ω(p · ρ)) ≤ 1/n10
by picking C large enough in the definition of p. The other case follows similarly.
Lemma G.2. The expected space used by the above oracle is O(pm).
Proof. Each vertex is sampled in Z with probability p and we keep all of its incident edges. Therefore, the expected number of edges saved is O(p ∑ v dv) = O(pm).
Note that the oracle satisfies the conditions of the K-noisy oracle in Definition 1.1. For example, if Ne ≥ C ′ρ for C ′ 1, Definition 1.1 only assumes that we incorrectly classify e with probability 1/C ′, whereas the oracle presented above incorrectly classifies e with probability exp(−C ′)/n10 which is much smaller than the required 1/C ′.

heading: H LEARNABILITY RESULTS
text: In this section, we give formal learning bounds for efficient predictor learning for edge heaviness. In particular, we wish to say that a good oracle or predictor for edge heaviness and related graph parameters can be learned efficiently using few samples if we observe graph instances drawn from a distribution. We can view the result of this section, which will be derived via the PAC learning framework, as one formalization of data driven algorithm design. Our results are quite general but we state simple examples throughout the exposition for clarity. Our setting is formally the following.
Suppose there is an underlying distribution D which generates graph instances H1, H2, · · · all on n vertices. Note that this mirrors some of our experimental setting, in particular our graph datasets which are similar snapshots of a dynamic graph across time.
Our goal is to efficiently learn a good predictor f among some family of functions F . The input of each f is a graph instance H and the output is a feature vector in k dimensions. The feature vector represents the prediction of the oracle and can encapsulate a variety of different meanings. One example is when k = |E| and f outputs an estimate of edge heaviness for all edges. Another is when k << |E| and f outputs the id’s of the k heaviest edges. We also think of each input instanceH as encoded in a vector in Rp for p ≥ ( n 2 ) (for example, each instance is represented as an
adjacency matrix). Note that we allow for p > ( n 2 ) if for example, each edge or vertex for H ∼ D also has an endowed feature vector.
To select the ‘best’ f , we need to precisely define the meaning of best. Note that in many settings, this involves a loss function which captures the quality of a solution. Indeed, suppose we have a loss function L : f ×H → R which represents how well a predictor f performs on some input H . An example of L could be squared error from the output of f to the true edge heaviness values of edges in H . Note that such a loss function clearly optimizes for predicting the heavy edges well.
Our goal is to learn the best function f ∈ F which minimizes the following objective:
EH∼D[L(f,H)]. (1)
Let f∗ be such the optimal f ∈ F , and assume that for each instance H and each f ∈ F , f(H) can be computed in time T (p, k). For example, suppose graphs drawn from D possess edge features in Rd, and that our family F is parameterized by a single vector θ ∈ Rd and represents linear functions which outputs the dot product of each edge feature with θ. Then it is clear that T (p, k) is a (small) polynomial in the relevant parameters.
Our main result is the following.
Theorem H.1. There is an algorithm which after poly(T (p, k), 1/ ) samples, returns a function f̂ that satisfies EH∼D[L(f̂ , H)] ≤ EH∼D[L(f∗, H)] + with probability at least 9/10.
We remark that one can boost the probability of success to 1 − δ by taking additional log(1/δ) multiplicative samples.
The above theorem is a PAC-style bound which shows that only a small number of samples are needed in order to ensure a good probability of learning an approximately-optimal function f̂ . The algorithm to compute f̂ is the following: we simply minimize the empirical loss after an appropriate number of samples are drawn, i.e., we perform empirical risk minimization. This result is proven by Theorem H.3. Before introducing it, we need to define the concept of pseudo-dimension for a function class which is the more familiar VC dimension, generalized to real functions. Definition H.2 (Pseudo-Dimension, Definition 9 Lucic et al. (2018)). Let X be a ground set and F be a set of functions from X to the interval [0, 1]. Fix a set S = {x1, · · · , xn} ⊂ X , a set of real numbers R = {r1, · · · , rn} with ri ∈ [0, 1] and a function f ∈ F . The set Sf = {xi ∈ S | f(xi) ≥ ri} is called the induced subset of S formed by f and R. The set S with associated values R is shattered by F if |{Sf | f ∈ F}| = 2n. The pseudo-dimension of F is the cardinality of the largest shattered subset of X (or∞).
The following theorem relates the performance of empirical risk minimization and the number of samples needed, to the notion of pseudo-dimension. We specialize the theorem statement to our situation at hand. For notational simplicity, we define A be the class of functions in f composed with L: A := {L ◦ f : f ∈ F}. Furthermore, by normalizing, we can assume that the range of L is equal to [0, 1]. Theorem H.3 (Anthony & Bartlett (1999)). Let D be a distribution over graph instances and A be a class of functions a : H → [0, 1] with pseudo-dimension dA. Consider t i.i.d. samples H1, H2, . . . ,Ht from D. There is a universal constant c0, such that for any > 0, if t ≥ c0 · dA/ 2, then we have ∣∣∣∣∣1t t∑ i=1 a (Hi)− EH∼D a(H)
∣∣∣∣∣ ≤ for all a ∈ A with probability at least 9/10.
The following corollary follows from the triangle inequality. Corollary H.4. Consider a set of t independent samples H1, . . . ,Ht from D and let â be a function in A which minimizes 1t ∑t i=1 a(Hi). If the number of samples t is chosen as in Theorem H.3, then
EH∼D[â(H)] ≤ EH∼D[a∗(H)] + 2
holds with probability at least 9/10.
The main challenge is to bound the pseudo-dimension of our given function class A. To do so, we first relate the pseudo-dimension to the VC dimension of a related class of threshold functions. This relationship has been fruitful in obtaining learning bounds in a variety of works such as Lucic et al. (2018); Izzo et al. (2021).
Lemma H.5 (Pseudo-dimension to VC dimension, Lemma 10 in Lucic et al. (2018)). For any a ∈ A, let Ba be the indicator function of the region on or below the graph of a, i.e., Ba(x, y) = sgn(a(x)− y). The pseudo-dimension ofA is equivalent to the VC-dimension of the subgraph class BA = {Ba | a ∈ A}.
Finally, the following theorem relates the VC dimension of a given function class to its computational complexity, i.e., the complexity of computing a function in the class in terms of the number of operations needed. Lemma H.6 (Theorem 8.14 in Anthony & Bartlett (1999)). Letw : Rα×Rβ → {0, 1}, determining the class W = {x→ w(θ, x) : θ ∈ Rα}. Suppose that any w can be computed by an algorithm that takes as input the pair (θ, x) ∈ Rα ×Rβ and returns w(θ, x) after no more than r of the following operations:
• arithmetic operations +,−,×, and / on real numbers,
• jumps conditioned on >,≥, <,≤,=, and = comparisons of real numbers, and
• output 0, 1,
then the VC dimension ofW is O(α2r2 + r2α logα).
Combining the previous results allows us prove Theorem H.1. At a high level, we are instantiating Lemma H.6 with the complexity of computing any function in the function class A.
Proof of Theorem H.1. First by Theorem H.3 and Corollary H.4, it suffices to bound the pseudodimension of the class A = L ◦ F . Then from Lemmas H.5, the pseudo-dimension of A is the VC dimension of threshold functions defined by A. Finally from Lemma H.6, the VC dimension of the appropriate class of threshold functions is polynomial in the complexity of computing a member of the function class. In other words, Lemma H.6 tells us that the VC dimension of BA as defined in Lemma H.5 is polynomial in the number of arithmetic operations needed to compute the threshold function associated to some a ∈ A. By our definition, this quantity is polynomial in T (p, k). Hence, the pseudo-dimension of G is also polynomial in T (p, k) and the result follows.
Note that we can consider initializing Theorem H.1 with specific predictions. If the family of oracles we are interested in is efficient to compute (which is the case of the predictors we employ in our experiments), then Theorem H.1 assures us that only polynomially many samples are required (in terms of the computational complexity of our function class), to be able to learn a nearly optimal oracle. Furthermore, computing the empirical risk minimizer needed in Theorem H.1 is also efficient for a wide verity of function classes. For example in practice, we can simply use gradient descent or stochastic gradient descent for a range of predictor models, such as regression or even general neural networks.
We remark that our learnability result is in similar in spirit to one given in the recent learningaugmented paper Dinitz et al. (2021). There, they derive sample complexity learning bounds for the different algorithmic problem of computing matchings in a graph (not in a stream). Since they specialize their analysis to a specific function class and loss function, their bounds are tighter compared to the possibly loose polynomial bounds we have stated. However, our analysis above is more general as it allows for a variety of predictors and loss functions to measure the quality of the predictions.

Review summaries:
The paper proposes a one pass streaming algorithms for estimating the number of triangles in adjacency list and arbitrary order models and 4-cycle in arbitrary edge arrival order. The authors propose algorithms for these streaming models under the assumption of a "heavy" edge oracle/ML model. The paper support theoretical claims with empirical experiments.

The line of research of improving sketching data structures/sampling with the help of learned models is becoming quite popular. This paper follows this line of research and applies this paradigm to the problem of cycle counting in graph streams ( specifically triangles and four-cycles).  It provides a theoretical framework for analyzing Oracle-based problems, analyzing the paradigm's space bounds in cycle counting, and providing lower bounds for the problems. 

Counting small length cycles in graph streams is an important graph mining primitive. For example, triangles, i.e., cycles of length 3, play an important role in analyzing social networks. Due to the importance of triangle counting, a wide variety of streaming algorithms in different graph steaming models have been proposed over the years.  This work asks the following question: if there is an oracle than can provide information to whether an edge participates in many or few triangles, can we improve the space required?  This work comes as a natural contribution to  a recent series of works on streaming algorithms that assume the existence of an oracle of some form.  The authors formalize the notion of an oracle in two ways, similarly to classification and regression. The former is defined in definition 1.1 where the oracle decides whether or not an edge is "heavy", whereas the latter is termed as the "noisy value oracle" (definition 1.2). The authors contribute to the problem of counting C3s in the incidence and adjacency models assuming a learner, and for C4s in the edge stream model. The authors present first the key idea of their algorithm assuming a perfect oracle, and then show that under certain conditions it works for noisy oracles. For C4s  An overview of their results is given in Table 1, together with a nice overview of the state-of-the-art algorithms.  In terms of experiments, the authors illustrate a variety of learners, learned from in- and out-of-sample.  They show that their methods achieve for some learners non-trivial improvement over various other competitors.