<?xml-model href='http://www.tei-c.org/release/xml/tei/custom/schema/relaxng/tei_all.rng' schematypens='http://relaxng.org/ns/structure/1.0'?><TEI xmlns="http://www.tei-c.org/ns/1.0">
	<teiHeader>
		<fileDesc>
			<titleStmt><title level='a'>Triangle and Four Cycle Counting with Predictions in Graph Streams</title></titleStmt>
			<publicationStmt>
				<publisher></publisher>
				<date>2022</date>
			</publicationStmt>
			<sourceDesc>
				<bibl> 
					<idno type="par_id">10330046</idno>
					<idno type="doi"></idno>
					<title level='j'>International Conference on Learning Representations</title>
<idno></idno>
<biblScope unit="volume"></biblScope>
<biblScope unit="issue"></biblScope>					

					<author>Justin Y Chen</author><author>Talya Eden</author><author>Piotr Indyk</author><author>Honghao Lin</author><author>Shyam Narayanan</author><author>Ronitt Rubinfeld</author><author>Sandeep Silwal</author><author>Tal Wagner</author><author>David P. Woodruff</author><author>Michael Zhang</author>
				</bibl>
			</sourceDesc>
		</fileDesc>
		<profileDesc>
			<abstract><ab><![CDATA[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. * All authors contributed equally.
TRIANGLE COUNTING IN THE ADJACENCY LIST MODELWe 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( -2 m 2/3 /T 1/3 , -1 m 1/2 )), given in Theorem 1.1. We defer the pseudocode]]></ab></abstract>
		</profileDesc>
	</teiHeader>
	<text><body xmlns="http://www.tei-c.org/ns/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink">
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="1">INTRODUCTION</head><p>Counting the number of cycles in a graph is a fundamental problem in the graph stream model (e.g., <ref type="bibr">Atserias et al. (2008)</ref>; <ref type="bibr">Bera &amp; Chakrabarti (2017)</ref>; <ref type="bibr">Seshadhri et al. (2013)</ref>; <ref type="bibr">Kolountzakis et al. (2010)</ref>; <ref type="bibr">Bar-Yossef et al. (2002)</ref>; <ref type="bibr">Kallaugher et al. (2019)</ref>). 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 <ref type="bibr">(Prat-P&#233;rez et al., 2012;</ref><ref type="bibr">Farkas et al., 2011)</ref>, and is used to discover motifs in protein interaction networks <ref type="bibr">(Milo et al., 2002)</ref>, understand social networks <ref type="bibr">(Foucault Welles et al., 2010)</ref>, and evaluate large graph models <ref type="bibr">(Leskovec et al., 2008)</ref>. See Al Hasan &amp; <ref type="bibr">Dave (2018)</ref> for a survey of these and other applications.</p><p>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.</p><p>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, F p -Moments or (k, p)-Cascaded Norms -can all achieve space bounds that are better than those provided by "classical" algorithms, see, e.g., <ref type="bibr">Hsu et al. (2019a)</ref>; <ref type="bibr">Cohen et al. (2020)</ref>; <ref type="bibr">Jiang et al. (2020)</ref>; <ref type="bibr">Eden et al. (2021)</ref>; <ref type="bibr">Du et al. (2021)</ref>. More generally, learning-based approaches have had wide success in other algorithmic tasks, such as data structures <ref type="bibr">(Kraska et al., 2018;</ref><ref type="bibr">Ferragina et al., 2020;</ref><ref type="bibr">Mitzenmacher, 2018;</ref><ref type="bibr">Rae et al., 2019;</ref><ref type="bibr">Vaidya et al., 2021)</ref>, online algorithms <ref type="bibr">(Lykouris &amp; Vassilvtiskii, 2018;</ref><ref type="bibr">Purohit et al., 2018;</ref><ref type="bibr">Gollapudi &amp; Panigrahi, 2019;</ref><ref type="bibr">Rohatgi, 2020;</ref><ref type="bibr">Wei, 2020;</ref><ref type="bibr">Mitzenmacher, 2020;</ref><ref type="bibr">Lattanzi et al., 2020;</ref><ref type="bibr">Bamas et al., 2020)</ref>, similarity search <ref type="bibr">(Wang et al., 2016;</ref><ref type="bibr">Dong et al., 2020)</ref> and combinatorial optimization <ref type="bibr">(Dai et al., 2017;</ref><ref type="bibr">Balcan et al., 2017;</ref><ref type="bibr">2018a;</ref><ref type="bibr">b;</ref><ref type="bibr">2019)</ref>. See the survey and references therein for additional works <ref type="bibr">(Mitzenmacher &amp; Vassilvitskii, 2020)</ref>.</p><p>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.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="1.1">OUR RESULTS AND COMPARISON TO PREVIOUS THEORETICAL WORKS</head><p>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.</p><p>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 <ref type="table">1</ref>.</p><p>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 <ref type="bibr">(Braverman et al., 2013</ref>, Section 1), <ref type="bibr">(McGregor et al., 2016, Section 1.2</ref>) 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.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="1.1.1">PERFECT ORACLE</head><p>Our first results apply for the case that the algorithms are given access to a perfect heavy edge oracle. That is, for some threshold &#961;, the oracle perfectly predicts whether or not a given edge is incident to at least &#961; triangles (four cycles). We describe how to relax this assumption in Section 1.1.2.</p><p>Adjacency List Model All edges incident to the same node arrive together. We show: Table <ref type="table">1</ref>: Our results compared to existing theoretical algorithms. &#8710; E (&#8710; V ) denotes the maximum number of triangles incident to any edge (vertex), and &#954; denotes the arboricity of the graph.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>Problem</head><p>Previous Results (no oracle) Our Results</p><p>Triangle, Adjacency O( -<ref type="foot">foot_1</ref> m/ &#8730; T ), 1-pass <ref type="bibr">(McGregor et al., 2016)</ref> O(min( -2 m 2/3 /T<ref type="foot">foot_0</ref>/3 , -1 m 1/2 )), 1-pass</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>Triangle, Arbitrary</head><p>O( -2 m 3/2 /T ), 3-pass <ref type="bibr">(McGregor et al., 2016)</ref> O( -2 m/ &#8730; T ), 2-pass <ref type="bibr">(McGregor et al., 2016)</ref> O( -2 (m/ &#8730; T + m&#8710; E /T )), 1-pass <ref type="bibr">(Pagh &amp; Tsourakakis, 2012)</ref> O( -1 (m/ &#8730; T +m 1/2 )), O( -2 (m/T 2/3 + m&#8710; E /T + m &#8730; &#8710; V /T )), 2-pass 1-pass <ref type="bibr">(Kallaugher &amp; Price, 2017)</ref> O(poly( -1 )(m&#8710; E /T + m &#8730; &#8710; V /T )), 1-pass <ref type="bibr">(Jayaram &amp; Kallaugher, 2021)</ref> O(poly( -1 )m&#954;/T ), multi-pass <ref type="bibr">(Bera &amp; Sheshadhri, 2020)</ref> </p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>4-cycle, Arbitrary</head><p>O( -2 m/T 1/4 ), 3-pass <ref type="bibr">(McGregor &amp; Vorotnikova, 2020)</ref> O(T 1/3 + -2 m/T 1/3 ), O( -2 m/T 1/3 ), 3-pass <ref type="bibr">(Vorotnikova, 2020)</ref> 1-pass Theorem 1.1. There exists a one-pass algorithm, Algorithm 1, with space complexity 1 O(min( -2 m 2/3 /T 1/3 , -1 m 1/2 )) in the adjacency list model that, using a learning-based oracle, returns a (1 &#177; )-approximation to the number T of triangles with probability at least 2 7/10.</p><p>An overview of Algorithm 1 is given in Section 2, and the full analysis is provided in Appendix B.</p><p>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:</p><p>Theorem 1.2. There exists a one-pass algorithm, Algorithm 4, with space complexity O( -1 (m/ &#8730; T + &#8730; m)) in the arbitrary order model that, using a learning-based oracle, returns a (1 &#177; )-approximation to the number T of triangles with probability at least 7/10. An overview of Algorithm 4 is given in Section 3, and full details are provided in Appendix C.</p><p>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 &#8486;(min(m/ &#8730; T , m 3/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.</p><p>Four Cycle Counting. For four cycle counting in the arbitrary order model, we give Theorem 1.3 which is proven in Appendix D.</p><p>Theorem 1.3. There exists a one-pass algorithm, Algorithm 5, with space complexity O(T 1/3 + -2 m/T 1/3 ) in the arbitrary order model that, using a learning-based oracle, returns a (1 &#177; )approximation to the number T of four cycles with probability at least 7/10.</p><p>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 <ref type="bibr">McGregor et al. (2016)</ref> for all values of m and T . For a concrete example, consider the case that T = &#920;( &#8730; m).</p><p>In this setting previous bounds result in an O(m 3/4 )-space algorithm, while our algorithm only requires O( &#8730; m) space (for constant ).</p><p>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 <ref type="bibr">McGregor et al. (2016)</ref> (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 = &#8486;(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 &#8804; 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 <ref type="table">2</ref>). 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 <ref type="bibr">Pagh &amp; Tsourakakis (2012)</ref>; <ref type="bibr">Kallaugher &amp; Price (2017)</ref>; Bera &amp; Sheshadhri ( <ref type="formula">2020</ref>)). 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).</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="1.1.2">NOISY ORACLES</head><p>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 <ref type="figure">3</ref> in the Supplementary Section C.2).</p><p>Definition 1.1. For an edge e = xy in the stream, define N e as the number of triangles that contain both x and y. For a fixed constant K &#8805; 1 and for a threshold &#961; we say that an oracle O &#961; is a K-noisy oracle if for every edge e, 1 -K</p><p>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.</p><p>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 &#177; &#8730; K &#8226; )T , and uses space at most O(min</p><p>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/</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>&#8730;</head><p>T + &#8730; m)) 1-pass algorithm of Theorem 1.2 also works when Algorithm 4 is only given access to a K-noisy oracle.</p><p>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.</p><p>(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 R xy denote the number of triangles {x, z, y} so that x precedes z and z precedes y in the stream arrival order. Formally, R xy = |z : {x, y, z} &#8712; &#8710; and x &lt; s z &lt; s y| where x &lt; s y denotes that the adjacency list of x arrives before that of y in the stream.</p><p>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 R xy . We refer to such oracles as value oracles.</p><p>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 (&#945;, &#946;) value-prediction oracle outputs a random value p(e) where E[p(e)] &#8804; &#945;R e + &#946;, and Pr[p(e) &lt; Re &#955; -&#946;] &#8804; Ke -&#955; for some constant K and any &#955; &#8805; 1.</p><p>For this variant, we prove the following theorem. Theorem 1.5. Given an oracle with parameters (&#945;, &#946;), there exists a one-pass algorithm, Algorithm 2, with space complexity O( -2 log 2 (K/ )(&#945; + m&#946;/T )) in the adjacency list model that returns a (1 &#177; )-approximation to the number of triangles T with probability at least 7/10.</p><p>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.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>Experiments</head><p>We conduct experiments to verify our results for triangle counting on a variety of real world networks (see Table <ref type="table">2</ref>) 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 <ref type="bibr">(Shin et al., 2018)</ref> and WRS <ref type="bibr">(Shin, 2017)</ref>. In these works, the authors compare to previous empirical benchmarks such as the ones given in <ref type="bibr">Stefani et al. (2017)</ref>; <ref type="bibr">Han &amp; Sethu (2017)</ref>; <ref type="bibr">Lim &amp; Kang (2015)</ref> and demonstrate that their algorithms achieve superior estimates over these benchmarks. There are also other empirical works such as <ref type="bibr">Ahmed et al. (2017)</ref> and <ref type="bibr">Ahmed &amp; Duffield (2020)</ref> 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 <ref type="table">1</ref>. Nevertheless, we use ThinkD and WRS as part of our benchmarks due to their strong practical performance and code accessibility.</p><p>Implicit Predictors in Prior Works The idea of using a predictor is implicit in many prior works.</p><p>The optimal two pass triangle counting algorithm of <ref type="bibr">McGregor et al. (2016)</ref> 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 N e either exceeds or is under the threshold &#961; 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 <ref type="bibr">McGregor &amp; Vorotnikova (2020)</ref> also implicitly defines a heavy edge oracle using a small initial portion of the random stream (see Lemma 2.2 in <ref type="bibr">McGregor &amp; Vorotnikova (2020)</ref>). 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.</p><p>Preliminaries. G = (V, E) denotes the input graph, and n, m and T denote the number of vertices, edges and triangles (or four-cycles) in G, respectively. We use N (v) to denote the set of neighbors of a node v, and &#8710; to denote the set of triangles. In triangle counting, for each xy &#8712; E(G), we recall that N xy = |z : {x, y, z} &#8712; &#8710;| is the number of triangles incident to edge xy, and R xy = |z : {x, y, z} &#8712; &#8710;, x &lt; s z &lt; 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. Our algorithm works differently depending on the value of T . We first consider the case that T &#8805; (m/ ) 1/2 . Assume that for each sampled edge xy in the stream, we can exactly know the number of triangles R xy this edge contributes to T . Then the rate at which we would need to sample each edge would be proportional to p naive &#8776; -2 &#8710; E /T , where &#8710; 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, p 1 , and compute their contribution by keeping track of R xy 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 &#961;. We then use an observation from <ref type="bibr">McGregor et al. (2016)</ref>, that since for heavy edges R xy &gt; &#961;, it is sufficient to sample from the entire stream at rate p 3 &#8776; -2 /&#961;, in order to both detect if some edge xy is heavy and if so to estimate R xy .</p><p>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).</p><p>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 p 2 &gt; p 1 . 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.</p><p>When T &lt; (m/ ) 1/2 our algorithm becomes much simpler. We only consider two types of edges, light and heavy, according to some threshold T /&#961;. To estimate the contribution due to heavy edges we simply store them and keep track of their R xy values. To estimate the contribution due to light edges we sub-sample them with rate -2 &#8226; &#8710; E /T = -2 /&#961;. The total space we use is O( -1 &#8730; 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 R e , and we assume R e &#8804; p(e) &#8804; &#945; &#8226; R e , where &#945; &#8805; 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)/u e , were u e is a standard ERV. We then store the O(&#945; log(1/ )) edges e for which p(e)/u e is largest. Since we are in the adjacency list model, once we start tracking edge e = xy, we can also compute the true value R e 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(&#945; log(1/ )) edges that we store. Using the max-stability property of ERVs, max e R e /u e 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 R e /u e is largest is, with probability 1 -O( 3 ), in our list of the O(&#945; log(1/ )) largest p(e)/u e values that we store. Repeating this scheme r = O(1/ 2 ) times, we obtain independent estimates T /u 1 , . . . , T /u r , where u 1 , . . . , u r are independent ERVs. Taking the median of these then gives a (1 &#177; )-approximation to the total number T of triangles. We note that ERVs are often used in data stream applications (see, e.g., <ref type="bibr">Andoni (2017)</ref>), 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.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3">TRIANGLE COUNTING IN THE ARBITRARY ORDER MODEL</head><p>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.</p><p>In more detail, our algorithm works as follows. First, we set a heaviness threshold &#961;, so that if we predict an edge e to be part of &#961; 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 S L be a random sample of edges predicted to be light. Then, we count three types of triangles. The first counter, 1 , counts the triangles &#8710; = (e 1 , e 2 , e), where the first two edges seen in this triangle by the algorithm, represented by e 1 and e 2 , are both in S L . Note that we only count the triangle if e 1 and e 2 ,were both in S L at the time e arrives in the stream. Similarly, 2 counts triangles whose first two edges are in S L and H (in either order), and 3 counts triangles whose first two edges are in H. Finally, we return the estimate = 1 /p 2 + 2 /p + 3 . Note that if the first two edges in any triangle are light, they will both be in S L with probability p 2 , and if exactly one of the first two edges is light, it will be in S L with probability p. Therefore, we divide 1 by p 2 and 2 by p so that is an unbiased estimator.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4">EXPERIMENTS</head><p>We now evaluate our algorithm on real and synthetic data whose properties are summarized in Table <ref type="table">2</ref> (see Appendix F for more details).</p><p>Table <ref type="table">2</ref>: Datasets used in our experiments. Snapshot graphs are a sequence of graphs over time (the length of the sequence is given in parentheses) and temporal graphs are formed by edges appearing over time. The listed values for n (number of vertices), m (number of edges), and T (number of triangles) for Oregon and CAIDA are approximated across all graphs. The Oregon and CAIDA datasets come from <ref type="bibr">Leskovec &amp; Krevl (2014)</ref>; <ref type="bibr">Leskovec et al. (2005)</ref>, the Wikibooks dataset comes from <ref type="bibr">Rossi &amp; Ahmed (2015)</ref>, the Reddit dataset comes from <ref type="bibr">Leskovec &amp; Krevl (2014)</ref>; <ref type="bibr">Kumar et al. (2018)</ref>, the Twitch dataset comes from <ref type="bibr">Rozemberczki et al. (2019)</ref>, the Wikipedia dataset comes from <ref type="bibr">Rossi &amp; Ahmed (2015)</ref>, and the Powerlaw graphs are sampled from the Chung-Lu-Vu random graph model with expected degree of the i-th vertex proportional to 1/i 2 <ref type="bibr">(Chung et al., 2003)</ref>.</p><p>We now describe the edge heaviness predictors that we use (see also Table <ref type="table">2</ref>). 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.</p><p>&#8226; 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, N e , 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 N e value is 0.</p><p>&#8226; Prefix: In the WikiBooks temporal graph, we use the exact N e counts on the first half of the graph edges (when sorted by their timestamps) as the predicted values for the second half.</p><p>&#8226; Linear Regression: In the Reddit Hyperlinks temporal graph, we use a separate dataset <ref type="bibr">(Kumar et al., 2019)</ref> 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</p><p>We then train a linear regressor to predict N e given the edge embedding f (e). Training is done on a prefix of the first half of the edges.</p><p>&#8226; Link Prediction (GNN): For each of the two networks, we start with a graph that has twice as many edges as listed in Table <ref type="table">2</ref>, (&#8764; 1.1 &#8226; 10 5 edges for Twitch and 9.2 &#8226; 10 4 edges for Wikipedia).</p><p>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 <ref type="bibr">Zhang &amp; Chen (2018)</ref> 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 N uv , the number of triangles on edge uv. See Section F.2 for details of training methodology.</p><p>&#8226; Expected Value (EV): In the Powerlaw graph, the predicted number of triangles incident to each N e is its expected value, which can be computed analytically in the CLV random graph model.</p><p>Baselines. We compare our algorithms with the following baselines.</p><p>&#8226; ThinkD and WRS (Arbitrary Order): These are the state of the art empirical one-pass algorithms from <ref type="bibr">Shin et al. (2018)</ref> and <ref type="bibr">Shin (2017)</ref> 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 <ref type="bibr">(Shin et al., 2020;</ref><ref type="bibr">Shin, 2020</ref>).</p><p>&#8226; MVV (Arbitrary Order and Adjacency List): We use the one pass streaming algorithms given in <ref type="bibr">McGregor et al. (2016)</ref> for the arbitrary order model and the adjacency list model.</p><p>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, &#177; one standard deviation.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4.1">RESULTS FOR ARBITRARY ORDER TRIANGLE COUNTING EXPERIMENTS</head><p>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 &#961;, which is the heaviness threshold. In our theoretical analysis, we assume knowledge of a lower bound on T in order to set p and &#961;, 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.</p><p>Oregon and CAIDA In Figures <ref type="figure">1(a</ref>) 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 <ref type="figure">1</ref>. As shown in Figure <ref type="figure">2</ref>, 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 <ref type="figure">4</ref>(a) in Supplementary Section F.4.</p><p>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 <ref type="figure">2</ref> Figures <ref type="figure">2(b</ref>) 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.</p><p>Reddit Our results are displayed in Figure <ref type="figure">1</ref>(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).</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>Wikibooks and Powerlaw</head><p>For Wikibooks, we see in Figure <ref type="figure">1</ref>(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 <ref type="figure">1</ref>(f). Here too we see that as the space allocation increases, our algorithm outperforms ThinkD, MVV, and WRS.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>Twitch and Wikipedia</head><p>In Figure <ref type="figure">1</ref>(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 <ref type="figure">4</ref>(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). In this section, we prove correctness and bound the space of Algorithm 1, thus proving Theorem 1.1.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>Results for Adjacency</head><p>In the adjacency list model, recall that we have a total ordering on nodes &lt; s based on the stream ordering, where x &lt; s y if and only if the adjacency list of x arrives before the adjacency list of y in the stream. For each xy &#8712; E(G), we define</p><p>We first give a detailed overview of the algorithm. We first consider the case when T &#8805; (m/ ) Further, we will show that not only can we use S aux to recognize whether R xy is large, but also to estimate R xy (Lemma B.3). What remains to handle is the medium edges. Since medium edges have higher values of R xy than light edges, we sample with a larger rate, p 2 , to reduce variance. However, we show there cannot be too many medium edges, so we do not pay too much extra storage space.</p><p>The overall space we use is O( -2 m 2/3 /T 1/3 ).</p><p>When T &lt; (m/ ) 1/2 our algorithm becomes much simpler. Let &#961; = &#8730; m/ . We define the edge xy to be heavy if R xy &#8805; T /&#961;, 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 /&#961; to estimate T L . The total space we use is O( -1 &#8730; m), which is optimal in this case. See Algorithm 1 for more details of the implementation.</p><p>Algorithm 1 Counting Triangles in the Adjacency List Model 1: Input: Adjacency list edge stream and an oracle O that outputs HEAVY if R xy &#8805; T /&#961; and LIGHT otherwise. 2: Output: An estimate of the triangle count T . B av = 1 {seen av twice}.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>13:</head><p>for each incident edge vu do</p><p>else {uv is either MEDIUM or HEAVY} 19:</p><p>With probability p 2 , S M = {vu} &#8746; S M . 25: return:</p><p>In the adjacency list model, we assume the oracle can predict whether R xy &#8805; T c or not, where R xy is dependent on the node order. This may sometimes be impractical. However, observe that N xy &#8805; R xy and N xy = 3T . Hence, our proof still holds if we assume what the oracle can predict is whether N xy &#8805; T c , which could be a more practical assumption.</p><p>Recall the following notation from Section 2. We define the edge xy to be</p><p>We define H, M , and L as the set of heavy, medium, and light edges, respectively. Define T L = xy&#8712;L R xy . We define T H and T M similarly. Also, recall that since xy&#8712;E R xy = T = T L + T M + T H , it suffices to estimate of these three terms.</p><p>Lemma B.2. Let A be an edge set such that for each edge xy &#8712; A, R xy &#8804; T c , 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 &#964; for &#964; = 2 &#8226; c/&#945;, so that 1/&#964; = &#945; -2 1 c independently, for a sufficient large constant &#945;. Then, with probability at least 9/10, we have</p><p>To bound this, we notice that</p><p>By Chebyshev's inequality, we have that</p><p>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 p 3 = &#946; -2 log n/&#961; in the stream for a sufficiently large constant &#946;, and consider the set # = |xz has been sampled : {x, y, z} &#8712; &#8710; and x &lt; s z &lt; s y| .</p><p>Then we have the following: if R xy &#8805; &#961; 2 , with probability at least 1 -1 n 5 , we have</p><p>Proof. We first consider the case when R xy &#8805; &#961; 2 . For each edge i &#8712; |xz : {x, y, z} &#8712; &#8710; and x &lt; s z &lt; s y|, let X i = 1 if i has been sampled, or X i = 0 otherwise. We can see the X i are i.i.d. Bernoulli random variables and E[X i ] = p 3 . By a Chernoff bound we have</p><p>Therefore, we have</p><p>Alternatively, when R xy &lt; &#961; 2 , we have</p><p>We are now ready to prove Theorem 1.1, restated here for the sake of convenience.</p><p>Theorem 1.1. There exists a one-pass algorithm, Algorithm 1, with space complexity<ref type="foot">foot_2</ref> O(min( -2 m 2/3 /T 1/3 , -1 m 1/2 )) in the adjacency list model that, using a learning-based oracle, returns a (1 &#177; )-approximation to the number T of triangles with probability at least<ref type="foot">foot_3</ref> 7/10.</p><p>Proof. We first consider the case when T &#8805; (m/ ) 1/2 .</p><p>For each edge xy &#8712; H, from Lemma B.3 we have that with probability at least 1 -</p><p>&#8712; H, then with probability 1 -1 n 5 , xy will not contribute to A h . Taking a union bound, we have that with probability at least 1 -1/n 3 ,</p><p>We now turn to deal with the light and medium edges. For a light edge xy, it satisfies R xy &#8804; T /&#961; and therefore we can invoke Lemma B.2 with the parameter c set to &#961;. For a medium edge xy, it satisfies R xy &#8804; &#961; = T /(T /&#961;), and therefore we can invoke Lemma B.2 with the parameter c set to T /&#961;. Hence, we have that with probability 4/5,</p><p>Putting everything together, we have that with probability 7/10, |A h /p 3 + A m /p 2 + A l /p 1 -T | &#8804; 3 T. Now we analyze the space complexity. We note that there are at most &#961; medium edges. Hence, the expected total space we use is</p><p>When T &lt; (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 T L . The analysis is almost the same.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>B.1 NOISY ORACLES FOR THE ADJACENCY LIST MODEL</head><p>Proof of Theorem 1.4. We first consider the case that T &lt; (m/ ) 1/2 . Recall that at this time, our algorithms becomes that we save all the heavy edges xy such that p(e) &#8805; T / &#8730; m and sampling the light edges with rate p l = -1 / &#8730; 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 &#961; = T / &#8730; m, then we have the condition that for every edge e,</p><p>We will show that, (i)</p><p>Under the above conditions we can get that with probability at least 9/10 we can get a (1&#177;O( &#8730; K)&#8226; )-approximation of T by Chebyshev's inequality.</p><p>For (i), we divide H = H h &#8746; H l , where the edges in H h are indeed heavyedges, and the edges in H l are indeed lightedges. Then, it is easy to see that |H h | &#8804; T /&#961;. For every light edges, the probability that it is included in H l is at most K &#8226; Re &#961; , hence we have</p><p>For (ii), we also divide L = L l &#8746; L h similarly. Then we have</p><p>where X = e&#8712;L l ,e has been sampled R e , Y = e&#8712;L h ,e has been sampled R e . Similar to the proof in Lemma B.2, we have </p><p>Also, we have</p><p>When T &#8805; (m/ ) -&#946;] &#8804; Ke -&#955; for some constant K and any &#955; &#8805; 1.</p><p>Our algorithm is based on the following stability property of exponential random variables (see e.g. Andoni ( <ref type="formula">2017</ref>)) Lemma B.5. Let x 1 , x 2 , ..., x n &gt; 0 be real numbers, and let u 1 , u 2 , ...u n be i.i.d. standard exponential random variables with parameter &#955; = 1. Then we have that the random variable max( x1 u1 , ..., xn un ) &#8764; x u , where x = i x i and u &#8764; Exp(1). Lemma B.6. Let r = O(ln(1/&#948;)/ 2 ) and &#8804; 1/3. If we take r independent samples X 1 , X 2 , ..., X r from Exp(1) and let X = median(X 1 , X 2 , ..., X r ), then with probability 1 -&#948;, X &#8712; [ln 2(1 -), ln 2(1 + 5 )].</p><p>Proof. We first prove the following statement: with probability</p><p>where F is the cumulative density function of a standard exponential random variable.</p><p>Consider the case when F (X) &#8804; 1/2 -. We use the indicator variable Z i where</p><p>Therefore, we have with probability at most &#948;/2, F (X) &#8804; 1/2 -. Similarly, we have that with probability at most &#948;/2, F (X) &#8805; 1/2 + . Taking a union bound, we have that with probability at least</p><p>, so if we consider the two endpoints of F (X), we have</p><p>and</p><p>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 max e R e /u e . 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 (R e + &#946;)/u e is larger than T / log(K/ ). However, one issue here is we need the information of T . We can remove this assumption when &#946; = 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/ )(&#945; + m&#946;/T )), so every time when a new edge comes, we can search the minimum value M such that the total number of edges e that in at least one subroutine (p(e) + &#946;)/u e &gt; 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.</p><p>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(&#945;, &#946;). 2: Output: An estimate of the number T of triangles. 3: Initialize X &#8592; &#8709; and H = O( 1 2 log 2 (K/ )(&#945; + m&#946;/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 S i stores edges, Q i stores all the exponential random variables for each sampled edge, and A i stores the current maximum of each sample} 5:</p><p>S i &#8592; &#8709;, Q i &#8592; &#8709;, and A i &#8592; 0 . 6: while seeing edges adjacent to y in the stream do 7:</p><p>for i = 0 to c -2 do {Update the counters for each sample} 8:</p><p>for each incident edge yx do 10:</p><p>for i = 0 to c -2 do 11:</p><p>if xy &#8712; S i then {Finished counting C xy , update the current maximum} 12:</p><p>else {Put yx into the sample sets temporarily} 14:</p><p>Let Ryx be the predicted value of R yx .</p><p>15:</p><p>Ryx &#8592; Ryx + &#946;.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>16:</head><p>Generate</p><p>17:</p><p>Set M to be the minimal integer such that i s i &#8804; H, where s i = |{e &#8712; E | Re /u i e &#8805; M }|.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>18:</head><p>for i = 0 to c -2 do {Adjust the samples to be within the space limit} 19:</p><p>We are now ready to prove Theorem 1.5. We first recall the theorem.</p><p>Theorem 1.5. Given an oracle with parameters (&#945;, &#946;), there exists a one-pass algorithm, Algorithm 2, with space complexity O( -2 log 2 (K/ )(&#945; + m&#946;/T )) in the adjacency list model that returns a (1 &#177; )-approximation to the number of triangles T with probability at least 7/10.</p><p>Proof. It is easy to see that for the i-th subroutine, the value f (i) = max e R e /u i e is the sample from the distribution T /u, where u &#8764; Exp(1). And if the edge e i , for which the true value R ei /u i ei is the maximum value among E, is included in S i , 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.</p><p>We will first show that with probability at least 9/10 the following events will happen:</p><p>) for all i, where c 1 is a constant.</p><p>&#8226; (ii) Let s i be the number of the edge e in the i-th subroutine such that (p(e) + &#946;)/u i e &#8805; c 2 1 T / log 2 (K/ ), then i s i &#8804; c 2 ( 1 2 log 2 (K/ )(&#945; + m&#946;/T )) for some constant c 2 .</p><p>&#8226; (iii) p(e i ) + &#946; &#8805; c 1 f (i)/ log(K/ ) for all i.</p><p>For (i), recall that f (i) &#8764; T /u, where u &#8764; Exp(1). Hence, we have</p><p>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) + &#946; &lt; R e /&#955;] &lt; Ke -&#955; , similarly we can get that with probability at least 99/100, (iii) will happen.</p><p>For (ii), we first bound the expectation of s i . For each edge e, we have</p><p>) log 2 (K/ )/T . Hence, we have</p><p>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).</p><p>For the subroutine i, from (ii) we know that M will be always smaller than O(T / log 2 (K/ )), and from (i) and (iii) we get that (p(e i )+&#946;)/u i ei &#8805; &#8486;(T / log 2 (K/ )). Hence, the edge e i 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 &#177; )-approximation of T .</p><p>We note that when &#946; = 0, the space complexity will become O( 1 2 log 2 (K/ )&#945;), and in this case we will not need a lower bound of T .</p><p>We will also consider the following noise model. Definition B.7. A value-prediction oracle with parameter (&#945;, &#946;) is an oracle that, for any edge e, outputs a value p(e) for which Pr[p(e) &gt; &#955;&#945;R e + &#946;] &#8804; K &#955; , and Pr[p(e) &lt; Re &#955; -&#946;] &#8804; K &#955; for some constant K and any &#955; &#8805; 1.</p><p>The algorithm for this oracle is shown in Algorithm 3.</p><p>We now state our theorem. Theorem B.1. Given an oracle with parameter (&#945;, &#946;), there exists a one-pass algorithm, Algorithm 3, with space complexity O( K 2 &#945;(log n) 3 log log n + m&#946;/T ) in the adjacency list model that returns a (1 &#177; &#8730; K &#8226; )-approximation to T with probability at least 7/10.</p><p>Proof. Define q(e) = p(e) + &#946;, it is easy to see that from the condition we can get that</p><p>We define the set E i such that e &#8712; E i if and only if q(e) &#8712; I i . We can see</p><p>Similar to the proof in Lemma B.2, we can get that</p><p>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(&#945;, &#946;). 2: Output: An estimate of the number T of triangles. 3: Initialize S j i &#8592; &#8709; and A j i &#8592; 0 where i = O(log n) and j = O(log log n). p 0 = c -2 2 i &#946;/T and p i = c -2 2 i &#946;(log n) 2 /T for some constant c. Define I 0 = [0, 2&#946;) and for each incident edge yx do 7:</p><p>if xy &#8712; S j i then 8:</p><p>else 10:</p><p>Let Ryx be the predicted value of R yx .</p><p>11:</p><p>Search i such that ( Ryx + &#946;) &#8712; I i 12:</p><p>For each j let S j i &#8592; S j i &#8746; {yx} with probability p i . 13: for i = 0 to O(log n) do 14:</p><p>H &#8592; H + median(A j i )/p i 15: return: H .</p><p>For Var[Y ], recall that for an edge e such that R e &#8805; 2 i+1 &#946;, we have Pr</p><p>Re . Then, condition on the oracle O &#952; , we have</p><p>And</p><p>). Using Chebyshev's inequality and taking a median over O(log log n) independent trials, we can get</p><p>A similar argument also holds for I 0 , which means that after taking a union bound, with probability 9/10, the output of the algorithm 3 is a (1 &#177; &#8730; K &#8226; )approximation of T . Now we analyze the space complexity of Algorithm 3.</p><p>For i &#8805; 1, we have</p><p>and |E 0 | &#8804; m, hence we have that the total expectation of the space is</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>C OMITTED PROOFS FROM SECTION 3</head><p>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 w A,B represent the set of pairs of edges (u, v), where u &#8712; A, v &#8712; B, and u, v share a common vertex.  if (e, w) is a triangle then 12:</p><p>Increment 1 = 1 + 1.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>13:</head><p>for each w &#8712; w S L ,H do 14:</p><p>if (e, w) is a triangle then 15:</p><p>Increment 2 = 2 + 1.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>16:</head><p>for each w &#8712; w H,H do 17:</p><p>if (e, w) is a triangle then 18:</p><p>Recall that we first assume that Algorithm 4 is given access to a perfect oracle O &#961; . That is, for every edge e &#8712; E,</p><p>where T e as the number of triangles incident to the edge e.</p><p>Theorem 1.2. First, we assume that T &#8805; -2 . If not, our algorithm can just store all of the edges, since m &#8804; -1 &#8226; m/ &#8730; T .</p><p>For each integer i &#8805; 1, let E(i) denote the set of edges that are part of exactly i triangles, and let</p><p>Since each triangle has 3 edges, we have that i&#8805;1 i &#8226; E(i) = 3T.</p><p>Let T 1 denote the set of triangles whose first two edges in the stream are light (according to O &#961; ).</p><p>For every triangle t i in T 1 , let &#967; i denote the indicator of the event that the first two edges of t i are sampled to S L , and let 1 = i &#967; i . Since each &#967; i is 1 with probability p 2 , Ex[&#967; i ] = p 2 , and Var[&#967; i ] = p 2 -p 4 &#8804; p 2 . For any two variables &#967; i , &#967; j , they must be uncorrelated unless the triangles t i , t j share a light edge that is among the first two edges of t i and among the first two edges of t j . Moreover, in this case, Cov[&#967; i , &#967; j ] &#8804; Ex[&#967; i &#967; j ] = P(&#967; i = &#967; j = 1). This event only happens if the first two edges of both t i and t j are sampled in S L , but due to the shared edge, this comprises 3 edges in total, so P(&#967; i = &#967; j = 1) = p 3 . Hence, if we define t 12 i as the first two edges of t i in the stream for each triangle t i ,</p><p>The first line follows by adding the covariance terms; the second line follows since each light edge e has at most T 2 e pairs (t i , t j ) intersecting at e; the third line follows by summing over t = T e , ranging from 1 to &#961;, instead over e; and the last line follows since t&#8805;1 t &#8226; E(t) = 3T . Now, let T 2 denote the set of triangles whose first two edges in the stream are light and heavy (in either order). For every triangle t = (e 1 , e 2 , e 3 ) in T 2 , e 1 , e 2 are sampled to S L &#8746; H with probability p. Also all other triangles have no chance to contribute to 2 . Hence, Ex[ 2 ] = p &#8226; T 2 . Also, two triangles t i , t j &#8712; T 2 that intersect on an edge e have Cov(&#967; i , &#967; j ) = 0 only if e is light and e &#8712; t 12 i , t 12 j . In this case.</p><p>Cov(&#967; i , &#967; j ) &#8804; Ex[&#967; i &#967; j ] &#8804; p, since if e is added to S L (which happens with probability p) then &#967; i = &#967; j = 1 as the other edges in t 12 i , t 12 j are heavy and are added to H with probability 1. Therefore,</p><p>by the same calculations as was done to compute Var[ 1 ].</p><p>Finally, let T 3 denote the set of triangles whose first two edges in the stream are heavy. Then</p><p>) for any (possibly correlated) random variables X, Y, we have that</p><p>for some fixed constant C implies that, with probability at least 2/3, is a (1 &#177; )-multiplicative estimate of T .</p><p>Furthermore, the expected space complexity is O(mp</p><p>), since we are assuming that T &#8805; -2 . Hence, assuming that T is a constant factor approximation of T , the space complexity is O( -1 m/</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>C.2 PROOF OF THEOREM 1.2 FOR THE K-NOISY ORACLE</head><p>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 &#8712; (1 &#177; )T , and</p><p>Recall that in Definition 1.1, we defined a K-noisy oracle if the following holds. For every edge e,</p><p>We first visualize this model. To visualize this error model, in Figure <ref type="figure">3</ref> we have plotted N e versus the range 1 -K &#8226; &#961; Ne , K &#8226; Ne &#961; for K = 2. We set N e to vary on a logarithmic scale for clarity. For example, if N e exceeds the threshold &#961; by a factor of 2, there is no restriction on the oracle output, whereas if N e exceeds &#961; 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 &#961; (e) = HEAVY] if the oracle O &#961; is a perfect oracle.</p><p>Proof of Theorem C.1. We follow the proof of Theorem 4.1 from the main paper. Let T 1 be the set of triangles such that their first two edges in the stream are light according to the oracle. Let T 2 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 T 3 be the set of triangles for which their first two edges are determined heavy by the oracle. Furthermore, we define &#967; i for each triangle t i , t(e) for each edge e, and E(i), E i for each i &#8805; 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</p><p>First, note that the expectation (over the randomness of</p><p>Therefore, by the same computation as in Theorem 4.1, we have that, conditioning on the oracle,</p><p>A similar analysis to the above shows that Ex</p><p>Hence, as in Theorem 4.1, we have</p><p>) 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 &#8712; (1 &#177; O( )) &#8226; T with probability at least 2/3.</p><p>Finally, the expected space complexity is bounded by</p><p>since t&#8805;1 E(t) &#8226; t = 3T and K = O(1). Hence, setting &#961; and p as in the proof of Theorem 4.1 implies that the returned value is a (1 &#177; )-approximation of T , and the the space complexity is O( -1 (m/ &#8730; T + &#8730; m)) as before.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>C.3 LOWER BOUND</head><p>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 N uv &#8805; T /c for a pre-determined threshold c, and we assume c = o(m) and T /c &gt; 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 &#8486;(min(m/ &#8730; T , m 3/2 /T )) lower bound even with such an oracle. Theorem C.2. Suppose that the threshold of the oracle c = O(m q ), where 0 &#8804; q &lt; 1. Then for any T and m, T &#8804; m, there exists m = &#920;(m) and T = &#920;(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 &#8486;(m/ &#8730; T ) space. For any T and m, T = &#8486;(m 1+&#948; ) where max(0, q -1 2 ) &#8804; &#948; &lt; 1 2 , there exists m = &#920;(m) and T = &#920;(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 &#8486;(m 3/2 /T ) space.</p><p>When T &#8804; m, we consider the hubs graph mentioned in <ref type="bibr">Kallaugher &amp; Price (2017)</ref>. Definition C.3 (Hubs Graph, <ref type="bibr">Kallaugher &amp; Price (2017)</ref>). The hubs graph H r,d consists of a single vertex v with 2rd incident edges, and d edges connecting disjoint pairs of v's neighbors to form triangles.</p><p>It is easy to see that in H r,d , each edge has at most one triangle. Hence, there will not be any heavy edges of this kind in the graph. In <ref type="bibr">Kallaugher &amp; Price (2017)</ref>, the authors show an &#8486;(r &#8730; d) lower bound for the hubs graph. Lemma C.4 <ref type="bibr">(Kallaugher &amp; Price (2017)</ref>). Given r and d, there exist two distributions G 1 , G 2 on subgraphs G 1 and G 2 of H r,d , such that any algorithm which distinguishes them with probability at least 2/3 requires &#8486;(r &#8730; d) space, where G i has &#920;(rd) edges and</p><p>Now, given T and m, where T &#8804; m, we let r = &#920;(m/T ) and d = T . We can see H r,d has &#920;(m) edges and T triangles, and we need &#8486;(r</p><p>When T &gt; m, we consider the following &#8486;(m 3/2 /T ) lower bound in <ref type="bibr">Bera &amp; Chakrabarti (2017)</ref>.</p><p>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</p><p>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</p><p>Let the final resulting graph be denoted by G = (V, E) where</p><p>In <ref type="bibr">Bera &amp; Chakrabarti (2017)</ref>, the authors show by a reduction to the DISJ N/3 N problem in communication complexity, that we need &#8486;(N ) space to distinguish the case when G has 0 triangles from the case when G has at least b 2 d triangles.</p><p>Given m and T , T = &#920;(m 1+&#948; ) where 1 &#8804; &#948; &lt; 1/2, as shown in Bera &amp; Chakrabarti (2017), we can set b = N s and d = N s-1 where s = 1/(1 -2&#948;). This will make m = &#920;(N 2s ) and T = &#920;(N 3s-1 ), which will make the &#8486;(m 3/2 /T ) lower bound hold. Note that at this time each edge will have an O( 1 m )-fraction of triangles or an O( 1</p><p>)-fraction of triangles. Assume the threshold of the oracle c = O(m q ). When &#948; &#8805; max(0, q -1 2 ), there will be no heavy edges in the graph.</p><p>Theorem C.2 follows from the above discussion.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>D FOUR-CYCLE COUNTING IN THE ARBITRARY ORDER MODEL</head><p>In the 4-cycle counting problem, for each xy &#8712; E(G), define N xy = |z, w : {x, y, z, w} &#8712; | as the number of 4-cycles attached to edge xy.</p><p>In this section, we present the one-pass O(T 1/3 + -2 m/T 1/3 ) space algorithm behind Theorem 1.3 and the proof of the theorem. <ref type="foot">6</ref>We begin with the following basic idea.</p><p>&#8226; Initialize: C &#8592; 0, S &#8592; &#8709;. On the arrival of edge uv:</p><p>-With probability p, S &#8592; {uv} &#8746; S.</p><p>-C &#8592; C + |{{w, z} : uw, wz and zv &#8712; S}|.</p><p>&#8226; Return C/p 3 . Following the analysis in Vorotnikova (2020), we have</p><p>where &#8710; E and &#8710; W denote the maximum number of 4-cycles sharing a single edge or a single wedge.</p><p>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.</p><p>For the 4-cycles that have heavy wedges, we use an idea proposed in McGregor &amp; 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.</p><p>At this point, we have not yet estimated the number of 4-cycles having more than one heavy edge but without heavy wedges. However, <ref type="bibr">McGregor &amp; Vorotnikova (2020)</ref> shows this class of 4-cycles only takes up a small fraction of T , and hence we can get a (1 &#177; )-approximation to T even without counting this class of 4-cycles.</p><p>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 Published as a conference paper at ICLR 2022 Algorithm 5 Counting 4-cycles in the Arbitrary Order Model 1: Input: Arbitrary Order Stream and an oracle that outputs TRUE if N xy &#8805; T /&#961; and FALSE otherwise. 2: Output: An estimate of the number T of 4-cycles.</p><p>p &#8592; &#945; -2 log n/&#961; for a sufficiently large &#945;, 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 E H &#8592; {uv} &#8746; E H . 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.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>14:</head><p>if q(u, v) &#8805; pT 1/3 then 15:</p><p>if the end points of wedges in d are not in W then 19:</p><p>for each 4-cycle d formed with uv and e &#8712; E L do 22:</p><p>if the end points of wedges in d are not in W then 23:</p><p>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 N uv &#8805; 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 &#8712; 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.</p><p>We now prove Theorem 1.3, restated here for the sake of convenience.</p><p>Theorem 1.3. There exists a one-pass algorithm, Algorithm 5, with space complexity O(T 1/3 + -2 m/T 1/3 ) in the arbitrary order model that, using a learning-based oracle, returns a (1 &#177; )approximation to the number T of four cycles with probability at least 7/10.</p><p>Proof. From the Lemma 3 in Vorotnikova (2020), we know that with probability at least 9/10, we can get an estimate A w such that</p><p>Where T w is the number of the 4-cycles that have at least one heavy wedge. We note that if a 4cycle has two heavy wedges, it will be counted twice. However, <ref type="bibr">Vorotnikova (2020)</ref> shows that this double counting is at most O(T 2/3 ) = O( )T .</p><p>For the edge sampling algorithm mentioned in D, from the analysis in Vorotnikova (2020), we have</p><p>Notice that in our algorithm, the threshold of the heavy edges and heavy wedges are N uv &#8805; T 2/3 and N w &#8805; T 1/3 , respectively, which means Var[ A l p 3 ] = O( 2 T 2 ). Hence, we can get an estimate A l such that with probability at least 9/10,</p><p>where T l is the number of 4-cycles that have no heavy edges. Similarly, we have with probability at least 9/10,</p><p>where T h is the number of 4-cycles that have at most one heavy edge.</p><p>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 <ref type="bibr">McGregor &amp; Vorotnikova (2020)</ref> 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</p><p>which is what we need.</p><p>Now we analyze the space complexity. The expected number of light edges we sample is O(mp) = O( -2 m/T 1/3 ) and the expected number of nodes in S and edges in E S is O(2mp) = O( -2 m/T 1/3 ). The expected number of 4-cycles we store in D is O(T p 3 ) = 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 + -2 m/T 1/3 ).</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>E RUNTIME ANALYSIS</head><p>In this section, we verify the runtimes of our Algorithms 1, 2, 3, 4, and 5.</p><p>Proposition E.1. Algorithm 1 runs in expected time at most O min( -2 m 5/3 /T 1/3 , -1 m 3/2 ) in the setting of Theorem 1.1, or O min( -2 m 5/3 /T 1/3 , K &#8226; -1 m 3/2 ) in the setting of Theorem 1.4.</p><p>Proof. For each edge ab &#8712; S L &#8746; S M , we check whether we see both va and vb (lines 9-10) when looking at edges adjacent to v. So, this takes time |S L | + |S M | per edge in the stream. We similarly check for each edge in S aux (lines 11-12), so this takes time |S aux |. 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 S aux and S M to search or count for elements. Thus, the overall runtime is</p><p>This is at most O(m &#8226; S), where S is the space used by the algorithm. So, the runtime is O min( -2 m 5/3 /T 1/3 , -1 m 3/2 in the setting of Theorem 1.1, and is at most O min( -2 m 5/3 /T 1/3 , K &#8226; -1 m 3/2 ) in the setting of Theorem 1.4.</p><p>Proposition E.2. Algorithm 2 runs in time O( -2 (&#945; + m&#946;/T )m).</p><p>Proof. For each edge ab &#8712; S i for each 0 &#8804; i &#8804; 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( |S i |) for each edge we see in the stream. By storing each S i (and each Q i ) in a balanced binary search tree or a similar data structure, we can search for xy &#8712; S i 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 Q i , S i can take time O(log n)).</p><p>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 + |S i |) time up to line 16. The remainder of the lines take time O( -2 &#8226; m log n), since the slowest operation is potentially deleting an edge from each S i and a value from each Q i up to m times (for each edge).</p><p>Overall, the runtime is O(</p><p>, where S is the total space used by the algorithm. Hence, the runtime is O( -2 (&#945; + m&#946;/T )m).</p><p>Proposition E.3. Algorithm 3 runs in time O(K -2 (&#945; + m&#946;/T )m).</p><p>Proof. For each edge ab &#8712; S j i for each 1 &#8804; i &#8804; O(log n), 1 &#8804; j &#8804; 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( |S j i |) 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 &#8712; S i 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 Q j i 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 &#8226; O( |S i |) time up to line 12. Finally, lines 13-15 take time poly log n.</p><p>Overall, the runtime is O(m</p><p>, where S is the total space used by the algorithm. Hence, the runtime is O(K -2 (&#945; + m&#946;/T )m).</p><p>Proof Overall, the runtime is O(m</p><p>where S is the total space of the algorithm.</p><p>So, the runtime is</p><p>Proposition E.5. Algorithm 5 runs in time O -2 /T 1/3 &#8226; (n 3 + m 2 ) .</p><p>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 </p><p>As each edge is in E L with probability at most p and each edge is in S with probability at most p, the total runtime is</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>F ADDITIONAL EXPERIMENTAL RESULTS</head><p>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.</p><p>F.1 DATASET DESCRIPTIONS</p><p>&#8226; Oregon: 9 graphs sampled over 3 months representing a communication network of internet routers <ref type="bibr">Leskovec &amp; Krevl (2014)</ref>; <ref type="bibr">Leskovec et al. (2005)</ref>.</p><p>&#8226; CAIDA: 98 graphs sampled approximately weekly over 2 years, representing a communication network of internet routers <ref type="bibr">Leskovec &amp; Krevl (2014)</ref>; <ref type="bibr">Leskovec et al. (2005)</ref>.</p><p>&#8226; Reddit Hyperlinks: Network where nodes represent sub communities (subreddits) and edges represent posts that link two different sub communities <ref type="bibr">Leskovec &amp; Krevl (2014)</ref>; <ref type="bibr">Kumar et al. (2018)</ref>.</p><p>&#8226; WikiBooks: Network representing Wikipedia users and pages, with editing relationships between them <ref type="bibr">Rossi &amp; Ahmed (2015)</ref>.</p><p>&#8226; 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. <ref type="bibr">Rozemberczki et al. (2019)</ref> &#8226; Wikipedia: This is a co-occurrence network of words appearing in the first million bytes of the Wikipedia dump. <ref type="bibr">Mahoney (2011)</ref> &#8226; 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/i 2 <ref type="bibr">Chung et al. (2003)</ref>. 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 &lt; j is proportional to 1/(ij) 2 .</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>F.2 DETAILS ON LINK PREDICTION ORACLE</head><p>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 <ref type="bibr">Zhang &amp; Chen (2018)</ref>. 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.</p><p>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 R uv . For the arbitrary order model, we use the same technique as above to predict N (u) and N (v), and estimate N uv .</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>F.3 PARAMETER SELECTION FOR ALGORITHM 2</head><p>We need to set two parameters for Algorithm 2: p, which is the edge sampling probability, and &#952;, which is the heaviness threshold. In our theoretical analysis, we assume knowledge of a lower bound on T in order to set p and &#952;, 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.</p><p>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 &#8226; Z of the edge 'slots' for heavy edges. The constant 0.3 is fixed throughout all our experiments.</p><p>We then set p = 0.7 &#8226; 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.</p><p>Call the first Z edges of the stream the early phase and the rest of the edges the late phase.</p><p>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).</p><p>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.</p><p>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.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>F.4 ADDITIONAL FIGURES FROM ARBITRARY ORDER TRIANGLE COUNTING EXPERIMENTS</head><p>Additional figures for our arbitrary order triangle counting experiments are given in Figures <ref type="figure">4</ref> and<ref type="figure">5</ref>. </p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>F.5 EXPERIMENTAL DESIGN FOR ADJACENCY LIST EXPERIMENTS</head><p>We now present our adjacencly list experiments. At a high level overview, similarly to the arbitrary order experiments, for our learning-based algorithm, reserve the top 10% of the total space for storing the heavy edges. To do this in practice, we can maintain the heaviest edges currently seen so far and evict the smallest edge in the set when a new heavy edge is predicted by the oracle and we no longer have sufficient space. 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 <ref type="figure">6</ref> (with additional plots given in Figure <ref type="figure">7</ref>). 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. Additional details follow.</p><p>We use the same predictor for N xy in Section 4 as a prediction for R xy . 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 R uv 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.</p><p>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 R e &#8805; 5 under a random vertex arrival order. Hence, for this edges, intuitively we can estimate them using a slightly smaller space.</p><p>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.   We can see for the smaller side, there are very few edges e such that p(e) &#8804; 1 k R e -&#946;. 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.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>F.8 DETAILS ON ORACLE TRAINING OVERHEAD</head><p>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 <ref type="bibr">Hsu et al. (2019b)</ref>). To give more details, for this snapshot oracle, we simply calculate the N e 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.</p><p>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 &#8764; 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.</p><p>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 N e 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 ( <ref type="formula">2014</ref> </p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>G IMPLICIT PREDICTOR IN PRIOR WORKS</head><p>We prove that the first pass of the two pass triangle counting Algorithm given in Section 3.1 of <ref type="bibr">McGregor et al. (2016)</ref>, 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 <ref type="bibr">(McGregor et al., 2016, Section 3</ref>.1):</p><p>1. Sample each node z of the graph with probability p = C -2 log m/&#961; for some large constant C &gt; 0. Let Z be the set of sampled nodes.</p></div><note xmlns="http://www.tei-c.org/ns/1.0" place="foot" n="1" xml:id="foot_0"><p>We use O(f ) to denote O(f &#8226; polylog(f )).</p></note>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" n="2" xml:id="foot_1"><p>The success probability can be 1 -&#948; by running log(1/&#948;) copies of the algorithm and taking the median.</p></note>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" n="3" xml:id="foot_2"><p>We use O(f ) to denote O(f &#8226; polylog(f )).</p></note>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" n="4" xml:id="foot_3"><p>The success probability can be 1 -&#948; by running log(1/&#948;) copies of the algorithm and taking the median.</p></note>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" n="5" xml:id="foot_4"><p>Using 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.</p></note>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" n="6" xml:id="foot_5"><p>We assume 1 T 1/6 &#8804; O( ), which is the same assumption as in previous work</p></note>
		</body>
		</text>
</TEI>
