Manuscript Offprint
arXiv:2609.04505Statistics of Similarity Graphs in Node-Arrival Streams
Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.
Abstract
In this paper, we study several statistical problems on similarity graphs in the node-arrival streaming model, including degree moments, diversity index, degree-moment sampling, and diversity sampling. We develop constant-pass, sublinear-space streaming algorithms for these problems and establish space lower bounds that nearly match the upper bounds in their dependence on the stream length.
1 Introduction
Many statistical problems in data stream analysis, including distinct elements and frequency moments, are defined in terms of item frequencies, which count how many times each item occurs. In applications involving data provided to or generated by large language models, however, this notion may be too restrictive. For example, different prompts may request essentially the same task using different wording. Similarly, an LLM may generate documents that appear different but are semantically equivalent because of paraphrasing or summarization. In such settings, when measuring how often an item occurs, similar but nonidentical items should also be allowed to contribute. This motivates a similarity-aware generalization of frequency, in which each stream item contributes according to its similarity to the item of interest.
Once each pair of stream items is assigned a similarity score, the stream naturally induces a similarity graph, with stream items as nodes and edge weights representing pairwise similarities. The weighted degree of a node is precisely its similarity-aware frequency. Moreover, the graph also captures the relational structure that is not revealed in individual frequencies.
In our setting, the similarity graph is implicit: the stream presents only the data items, rather than the edges or edge weights of the graph, and pairwise similarities can be obtained only by evaluating a similarity function on items stored in memory. This leads to the central question of this paper:
How space-efficiently can we perform fundamental statistical tasks on an implicit similarity graph presented as a node-arrival stream?
We formalize this setting as follows. Let denote the data stream, and let be a symmetric similarity function satisfying for all . The similarity graph of is the complete weighted graph on the node set , with edge weight function for all . Thus, each edge has a weight in , with every node having a self-loop of weight . For each , let
which can be viewed as the similarity-weighted frequency of .
In this paper, we study the following statistics of the similarity graph:
-
: degree moments of . When f is the equality function, degenerates to the classical -th frequency moment . When f is Boolean, the quantity corresponds to the size of the self-similarity join of the set under f.
-
: diversity index of . characterizes the “level of diversity” of the set under the similarity function . When is the equality function, degenerates to the number of distinct elements in . When is Boolean, this quantity is also known as the Caro–Wei bound [11, 48] in the literature, and it gives a lower bound on the size of a maximum independent set in the graph.
-
-sampler: degree-moment sampler on that samples nodes with probability proportional to the -th power of their degrees; it outputs node with probability . When is the equality function, -sampler degenerates to the classical -sampler.
-
-sampler: diversity sampler on that samples nodes with probability proportional to the inverse of their degrees; it outputs node with probability . When is the equality function, -sampler degenerates to the classical -sampler.
The Computational Model. We work in the well-established data stream model [26, 1] for large-scale data processing. In this model, a sequence of data items arrive sequentially, while the available memory is too small to store the entire dataset. Our goal is to compute a function of the dataset using one or more linear scans of the stream. The main objective is to minimize the space usage of the algorithm and the number of passes needed over the data.
In this paper, we focus on node-arrival streams. The input is a sequence of items , where each item corresponds to a node of . We are also given access to a similarity function . The weights of are not provided explicitly. Instead, the weight between two nodes is computed on demand by evaluating , but only when the items corresponding to both nodes are stored in memory.
We believe that computing statistics of an implicit similarity graph provides a natural setting for studying node-arrival streams. In this context, nodes (data items) are the primary objects, while pairwise weights are derived objects that capture relationships or similarities between the nodes.
Notation and Conventions. We assume is a constant throughout the paper. When is clear from the context, we simply write , , and as , , and .
We measure the space complexity of our upper bounds in words and use a unit-cost RAM model. We assume that each stream item, each value returned by the similarity function , and each arithmetic quantity maintained by our algorithms can be represented using words. If each item requires bits to represent, then all of our upper bounds, when stated in bits, incur an additional multiplicative factor of . Our lower bounds are stated in bits and use only Boolean similarity functions.
We regard each stream item as a distinct node. Thus, node is represented by the pair . When there is no ambiguity, we use to refer to node as well as its associated item value.
For any , we say is a -approximation of if with probability at least . For some lower bounds, we are able to prove for larger approximation ratios. For any , we say is an -approximation of if with probability at least .
We use the notation to indicate that lies within the interval . For -sampling and -sampling, we slightly relax the sampling criterion by allowing a relative error . A -sampler (resp. -sampler) on fails with probability at most and conditioned on no failure, outputs node with probability (resp. ).
Our Results. We present the following algorithmic results in Section 2.
-
For any , a -approximation algorithm for diversity index DI uses words of space and three passes.
-
For any , a --sampler uses words of space and three passes.
-
For any and any , a -approximation algorithm for degree moment uses words of space and two passes.
-
For any and any , a --sampler uses words of space and two passes.
We supplement the results above with the following lower bounds in Section 3.
-
Any one-pass -approximation algorithm for diversity index DI needs bits of space. For any , any -pass -approximation algorithm for DI needs bits of space.
-
For any , any one-pass --sampler needs bits of space, and any -pass --sampler needs bits of space.
-
For any , any one-pass -approximation algorithm for needs bits of space. For any and , any -pass -approximation algorithm for needs bits of space.
-
For any and , any one-pass --sampler needs bits of space, and any -pass --sampler needs bits of space.
We summarize our main results in Table 1. The one-pass lower bounds rule out the possibility of obtaining one-pass sublinear-space streaming algorithms for diversity index, diversity sampling, degree moments and degree-moment sampling. Our constant-pass upper and lower bounds match in their dependence on , up to logarithmic factors.
| Problem | Upper bound | Constant-pass lower bound | One-pass lower bound |
|---|---|---|---|
| DI | 3 passes; | ||
| -sampling | 3 passes; | ||
| () | 2 passes; | ||
| -sampling | 2 passes; |
Table 1: Summary of our results. Upper bounds are in words and lower bounds are in bits; hides logarithmic factors in . All upper bounds hold for -approximation. The approximation guarantees for lower bound vary; see “Our Results” for details.
data streams cannot be applied to the statistical estimation of the similarity graph, where, as we have shown in this paper, strong polynomial space lower bounds hold.
Node-Arrival Streams. Node-arrival streams differ from the more widely studied edge-arrival model, in which the input consists of the edges of a graph (see, e.g., [43] for a survey). In the literature, the model considered in this paper is known as the implicit vertex-arrival model and has previously been studied in [24, 10, 18]. These works, however, focus specifically on the maximum independent set problem for certain geometric intersection graphs. More recently, [41] studied the cost of correlation clustering in the node-arrival model, whereas our focus is on statistical problems over similarity graphs.
Similarity-Aware Statistical Analysis. In more recent years, a few works have investigated data streams with near-duplicates [15, 16, 50]. The work [15] studied the problem in -dimensional Euclidean spaces and in metric spaces that admit efficient locality sensitive hashing. Its follow-up [16] examined -sampling in the same settings. More recently, [50] generalized the study of to general metric spaces. However, these works focus on a particular class of datasets, referred to as well-shaped data, corresponding to the special case of our framework in which is Boolean and transitive. Although these works also consider the case when transitivity does not hold and introduced the notion of min-partition based ambiguity, this definition is specifically designed for the problem and does not readily extend to other statistical functions.
A recent work [42] introduced a statistical estimation framework for noisy datasets based on the notion of mismatch-ambiguity. This approach also relies on the similarity graph representation of the input dataset induced by a similarity function. However, rather than directly computing statistics of , it assumes the existence of an underlying noiseless ground-truth dataset corresponding to the observed noisy dataset . The goal is then to estimate the statistics of , with the approximation ratio parameterized by a carefully defined mismatch-ambiguity measure , which captures the discrepancy between the similarity graphs and . The guarantees provided by this framework are meaningful only when is sufficiently small. At the same time, itself is unknown in practice, since the ground-truth dataset is not available.
Other Related Work. Degree moments have also been studied in the sublinear-time algorithms [25, 32, 33, 23]. That line of work focuses on achieving sublinear running time in the query model and assumes access to multiple types of graph queries (e.g., neighbor queries and degree queries), which differs substantially from our streaming setting.
The Caro–Wei bound has been studied in the streaming setting [17], but only for edge-arrival streams and the explicit vertex-arrival model. In the latter model, when a vertex arrives, the stream explicitly presents all edges such that has arrived earlier.
2 Algorithms
In this section, we present the algorithms for diversity index, diversity sampler, degree moments and degree-moment sampling. We assume that is known in advance to simplify the presentation. In Section 2.5, we discuss how to remove this assumption without an additional pass.
2.1 Diversity Index
We start with the diversity index DI. Our algorithm is described in Algorithm 1 with inline remarks.
The Ideas and Algorithm Descriptions. The first idea one may come up with to estimate is to sample the summands . However, the value of spans the interval , meaning that samples are needed to estimate DI up to an factor.
A natural idea to reduce the variance of the sampling approach is to partition the set of nodes into two groups, one, denoted by , containing high-degree nodes (roughly, those with degree at least ), and the other, denoted by , containing low-degree nodes. We then estimate their contributions to DI separately. However, in the streaming model, we cannot identify and store the two groups and explicitly using space. We resolve this issue by first sampling a witness set of size , which we store in memory. In the second pass, we use to classify all nodes as either high-degree nodes or low-degree nodes. For every high-degree node , we immediately calculate its estimated degree , and add to ; note that we do not store in memory. We can show that is a good estimate of (i.e. the total contribution of ). For low-degree nodes, we sample a subset of size and store it in memory. In the third pass, we compute the degree of each node in exactly, and then use to estimate . We can show that every node in has a degree with high probability. Therefore, a sample of size is sufficient to estimate the total contribution of accurately. Finally, we return as the estimation of DI.
The Analysis. We now analyze Algorithm 1 and establish the following theorem.
Theorem 1. Given an input data stream of length and a similarity function , for any , Algorithm 1 computes ()-approximation of , using three passes and words of space.
The space and pass complexities are clear from Algorithm 1. In the remainder of this section, we show the correctness.
Recall that in Algorithm 1, is the total similarity weight between and . Let and , where is defined at Line 1 of Algorithm 1. We have the following lemma.
Lemma 2. With probability at least , the following events hold: (1) , (2) , and (3) is a -approximation of .
Algorithm 1: Diversity index estimation
Input: a data stream of size and a similarity function , parameter
Output: a -approximation of
1 , ,
2 , ,
3 : an array of size , with entries initialized to stores a set of witnesses */
4 and : arrays of size , with entries initialized to stores samples drawn from low-degree nodes, and stores their degrees */
5 // Pass 1: obtain a ``witness'' set
6 foreach incoming do
7 for do
8 with probability ,
9 // Pass 2: use the witness set to classify nodes as either high-degree or low-degree nodes, and estimate the contribution of high-degree nodes.
10 foreach incoming do
11
12 if then
13 is classified as a high-degree node; add the estimated contribution of to */
14 else
15 /* is classified as a low-degree node */
16 for do with probability , obtain a sample of low-degree nodes */
18
19 // Pass 3: estimate the contribution of low-degree nodes by computing exact degrees of sampled low-degree nodes
20 foreach incoming do
21 for do
22
23 /* rescale to estimate the total contribution of low-degree nodes */
24
25 return .
Proof. Since all nodes in are sampled uniformly at random from , for any with , we have . By a Chernoff bound,
Therefore, with probability , the following event holds: for all with , ; consequently, . This implies that if , then , proving the first item.
On the other hand, for any with , we have . By a Chernoff bound,
Therefore, with probability , the following event holds: for all with , is a -approximation of . Consequently, is a -approximation of .
We condition on events in the rest of the proof, which hold with probability . If , then either (1) , or (2) and , where the second case implies , since is a -approximation of . Therefore,
proving the second item.
If , then , and thus is a -approximation of . As a result, is a -approximation of , proving the third item.
Let denote the event that Lemma 2 holds, then . The next lemma shows that, conditioned on , provides a good approximation to .
Lemma 3. Conditioned on , with probability at least , is a -approximation of .
Proof. For each , let be the -th sample in and . Fix any such that holds. Since each is sampled uniformly at random from , . By Lemma 2, for all we have
Let . We have . By a Chernoff bound,
Therefore, with probability , is a -approximation of the quantity .
By Lemma 2 and Lemma 3, with probability , and are -approximations of and , respectively. Since , is a -approximation of DI.
Algorithm 2: -sampling
Input: a data stream of size and a similarity function , parameter
Output: a node in sampled with probability inversely proportional to its degree
1
2
3 : arrays of size , with entries initialized to and are samples drawn from high-degree and low-degree nodes, respectively, with their corresponding degrees stored in and
4 // Pass 1: identify the witness set
5 run Pass 1 of Algorithm 1 with input to obtain the witness set
6 // Pass 2: classify nodes as either high-degree or low-degree nodes and obtain a sample from each group, denoted by and
7 parallel run Pass 2 of Algorithm 1, computing for each node the total similarity weight (denoted by ) in , see Line 11 in Algorithm 1, and get , the contribution of high-degree nodes to DI
8 foreach incoming do
9 if then
10
11 for do with probability ,
12 else
13
14 for do with probability ,
15 // Pass 3: get a sample using and
16 parallel run Pass 3 of Algorithm 1 and get , the contribution of low-degree nodes to DI
17 /* compute the degrees of nodes in and
18 foreach incoming do
19 for do
20
21
22 /* get one sample from each of and and then ``merge''
23 for do
24 with probability , break if is assigned
25 for do
26 with probability , break if is assigned
27 if or then
28 return Fail
29 else
30 return with probability or otherwise.
2.2 -Sampling
In this section, we consider -sampling. Our algorithm is described in Algorithm 2.
The Ideas and Algorithm Descriptions. We begin with a special case: when is the equality function, DI coincides with , the number of distinct elements in , and -sampling coincides with -sampling. A simple approach for -sampling is to sample each distinct element with probability , which ensures a good probability of sampling exactly one element. Given this outcome, the sampled element is uniformly distributed over all distinct elements in the data stream. For a general similarity function, a natural adaptation of this approach is to sample each node with probability , which ensures a good probability that the sample set contains exactly one node. Unfortunately, a node sampled in this manner does not necessarily follow the desired distribution.
For example, consider a graph consisting of three nodes and five edges (including self-loops) . In this case, and the probability of choosing Node 1 according to the -distribution is . On the other hand, if we first sample the three nodes independently into with probability , and , and output the node if exactly one node is sampled (i.e., ), the probability that Node 1 is sampled is
which is not equal to .
We thus take a different approach: we first sample a node uniformly at random, and then accept it with probability . To ensure successful acceptance, we run multiple Reservoir sampling structures in parallel, and at the end of the streaming process, repeatedly apply the rejection sampling procedure until a sample is accepted. The problem with this vanilla rejection sampling method is that it may require samples to obtain a single accepted sample, resulting in space complexity.
To reduce the space usage, we again partition the nodes into high-degree group and low-degree group as in Algorithm 1. We next perform rejection sampling on two groups with different rejection rates, and then properly merge the accepted samples in the two groups at the end. More precisely, in the first pass, we again try to sample a witness set, which is used in the second pass to partition the nodes into two groups using a degree-threshold roughly . At the same time, we obtain a random subset of size from each group. In the third pass, we compute the degree of the sampled nodes, and then perform rejection samplings on the two sample sets. For each node in the sample of the high-degree group, we use a rejection rate of , where we put a cap 1 in the minimization since the value may be larger than 1 due to the small inaccuracy of the high-low classification. For each node in the sample of the low-degree group, we use a rejection rate of . When we get one accepted sample from each group, we select one of the two accepted samples with a probability proportional to the DI contributions of the high-degree and low-degree groups, which can be approximated by running Algorithm 1 in parallel.
The Analysis. We now analyze Algorithm 2 and prove the following theorem.
Theorem 4. Given an input data stream of length and a similarity function , for any , Algorithm 2 is a --sampler; it uses three passes and words of space.
The pass and space complexities are clear from Algorithm 2. In the remainder of this section, we show the correctness.
W.l.o.g., assume ; otherwise , in which case we can store all nodes of the graph and perform the sampling offline.
Let be the event that both Lemma 2 and Lemma 3 hold. Then . For each , let be the -th sample in and be the -th sample in . We have the following lemma.
Lemma 5. Conditioned on , Algorithm 2 fails with probability at most .
Proof. By Lemma 2, conditioned on , for each , we have and . If , then
Similarly, if , then
By (1) and (2), with probability at most , either or occurs, causing Algorithm 2 to fail.
Lemma 6. Conditioned on , Algorithm 2 samples each node with probability in the range of .
Proof. We first show that conditioned on not being null, follows the distribution .
For any and , since is sampled from uniformly at random, we have
It follows that
where does not depend on . Since the probabilities sum to 1, we have
By a similar argument, for any ,
Without loss of generality, we assume that both and are not empty, otherwise Algorithm 2 is already a -sampler by (3) and (4). By Lemma 2, Lemma 3, and our choices of parameters, and are -approximation of and , respectively. Therefore,
By (3) and (5), for any , we have
By a similar argument, for any ,
□
By Lemma 2, Lemma 3 and Lemma 5, the total failure probability of Algorithm 2 is at most . By Lemma 5 and Lemma 6, for any , we have
which implies that
where the last equality holds since we have assumed that , and and .
Consequently, by down-scaling by a factor of 2, Algorithm 2 is a - -sampler using words of space.
2.3 -Estimation
In this section, we study -estimation. Our algorithm is described in Algorithm 3.
The Ideas and Algorithm Descriptions. We can use the same strategy as Algorithm 1 to estimate . The idea is to partition the nodes into a high-degree group and a low-degree group based on a degree threshold of approximately , using a witness set sampled in the first pass. Like before, we compute the contribution of the high-degree group by approximating each node's degree in the second pass, while the low-degree group's contribution is derived from a sample set with exact degrees in the third pass. As before, this approach needs three passes.
Algorithm 3: -estimation
Input: a data stream of size and a similarity function , parameter
Output: a -approximation of
1 , , ,
2 ,
3 : an array of size , with entries initialized to /* stores a set of witnesses */
4 , and : arrays of size , with entries initialized to /* contains samples drawn from , records whether each node in belongs to , and stores their degrees */
5 // Pass 1: obtain samples (witness set) and (low-degree candidates)
6 foreach incoming do
7 for do with probability ,
8 for do with probability ,
9 // Pass 2: estimate
10 foreach incoming do
11 for do
12 */
13
14 if then
15 */
16 else
17 */
18 for do
19
20 /* rescale to estimate the total contribution of low-degree nodes */
21
22 return .
However, for , we can compress three passes to two passes. The key observation is that we can prepare for a sample of the low-degree group in the first pass without identifying the low-degree nodes. We can then filter out high-degree nodes in in the second pass and use the remaining nodes to estimate the contribution of low-degree nodes. If, after filtering, the number of remaining nodes in is very small, then we know that the number of low-degree nodes in the whole dataset is small, and thus the contribution of low-degree nodes is negligible. Otherwise, we will obtain sufficiently many samples to accurately estimate the contribution of the low-degree nodes. This idea does not work for DI, since the contribution of a small number of low-degree nodes to DI may be dominant.
The Analysis. We now analyze Algorithm 3 and prove the following theorem.
Theorem 7. Given an input data stream of length and a similarity function , for any , there is an algorithm that computes ()-approximation of (), using two passes and words of space.
The pass and space complexities are clear from Algorithm 3. We now prove that with probability at least 2/3, Algorithm 3 outputs a -approximation of . By parallel repetition and taking the median, we can boost the success probability to 0.99 with an additional constant factor in the space bound.
Recall that in Algorithm 3, is the total similarity weight between and . Let and , where is defined at Line 1 of Algorithm 3. Let and be the estimated contributions of and , respectively.
We have the following lemma.
Lemma 8. With probability , the following events hold: (1) , (2) , and (3) is a -approximation of .
Proof. Since all nodes in are sampled uniformly at random from , for any with , we have . By a Chernoff bound,
Therefore, with probability , the following event holds: for all with , , and thus . This implies that if , then , proving the first item.
On the other hand, for any with , we have . By a Chernoff bound,
Therefore, with probability , the following event holds: for all with , is a -approximation of . Consequently, is a -approximation of when .
We condition on events and in the rest of the proof, which hold with probability .
If , then either (1) , or (2) and , where the second case implies , since is a -approximation of . Therefore,
proving the second item.
If , then , and thus is a -approximation of . As a result, is a -approximation of , proving the third item.
Let denote the event that Lemma 8 holds, then . The next lemma shows that, conditioned on , provides an approximation to up to a small additive error.
Lemma 9. Conditioned on , with probability at least , we have
Proof. For each , let be the -th sample in and . Fix any such that holds. Since each is sampled from uniformly at random, we have . Furthermore, by Lemma 8, for all we have
Let . Observe that
By Chebyshev's inequality,
The last inequality holds by noting that and .
Since and , with probability at least , we have
By Lemma 8 and Lemma 9, with probability , we have
and
Adding (6) and (7) gives
Since , with probability at least , Algorithm 3 returns a -approximation of .
Algorithm 4: -Sampling
Input: a data stream of size n and a similarity function f, parameter
Output: a node in sampled with probability proportional to the p-th power of its degree
1 , ,
2 , , ,
3 : an array of size , with entries initialized to 0 /* stores a set of witnesses */
4 , , and D: arrays of size , with entries initialized to 0 /* stores low-degree candidates, records whether a candidate belongs to L and D stores its degree */
5 // Pass 1: obtain the witness set and low-degree candidates
6 foreach incoming do
7 for do
8 | with probability ,
9 draw
10 if then
11 | insert into an empty entry of ; if no such entry exists, return Fail
12 // Pass 2: find the minimum of over all high-degree nodes and stored low-degree nodes
13 foreach incoming do
14 regenerate using the same random seed
15 for do
16 | /* compute the degrees of nodes in */
17
18 if then
19 */
20 if then
21 | /* update the current minimum using */
22 else
23 /* is classified as a low-degree node; mark all */
24 for do
25 | if then
26 for do
27 regenerate using the same random seed
28 if and then
29 | /* update the current minimum using a stored low-degree node */
30 if then return Fail
31 return r
2.4 -Sampling
In this section, we consider -sampling. Our algorithm is described in Algorithm 4.
The Ideas and Algorithm Descriptions. We can use the same strategy as -sampling to develop a three-pass algorithm for -sampling. The idea is to partition the nodes into a high-degree group and a low-degree group , based on a degree threshold of approximately , using a witness set sampled in the first pass. We then sample candidates from the two groups in the second pass and compute their exact degrees in the third pass. Rejection sampling can be applied within each group, after which the two samples are merged according to the -contributions of and . As before, this approach needs three passes.
However, it is not clear how to compress this rejection-sampling approach to two passes. We instead use the exponential-scaling approach. For every node , we draw an independent and scale it by . The node minimizing is sampled with probability .
The key observation is that we can store all low-degree nodes that may attain the minimum in the first pass, without identifying the low-degree nodes. Note that the minimum of is distributed according to , thus with high probability. Moreover, every node has degree at most . Therefore, if a low-degree node satisfies , then with high probability . We can thus store every node satisfying the latter condition in during the first pass. In the second pass, we use to classify the nodes, compute the exact degrees of the stored low-degree candidates, and process every high-degree node using its estimated degree. Consequently, every node that may attain the minimum is processed by the algorithm. This gives a two-pass, sublinear-space algorithm.
We note that in Algorithm 4, by “regenerate ” we mean regenerating the corresponding random variables using Nisan’s pseudorandom generator [47] with the same seed, which is stored in memory. Using Nisan’s generator incurs only an additional multiplicative factor in the space complexity and increases the error probability by at most . We omit these overheads throughout the paper.
The Analysis. We now analyze Algorithm 4 and prove the following theorem.
Theorem 10. Given an input data stream of length and a similarity function , for any and , Algorithm 4 is a -sampler; it uses two passes and words of space.
The pass and space complexities are clear from Algorithm 4. In the remainder of this section, we show the correctness.
W.l.o.g., assume ; otherwise, the stated space bound is at least , in which case we can store all nodes and perform the sampling offline.
Recall that is the total similarity weight between and . Let and , where is defined in Algorithm 4.
Lemma 11. With probability at least , the following events hold: (1) , (2) and (3) for any , .
Proof. Since all nodes in are sampled uniformly at random from , for any with , we have . By a Chernoff bound,
Therefore, with probability at least , every node of degree less than belongs to L. This proves the first item.
On the other hand, for every with , we have . By a Chernoff bound,
Therefore, with probability at least , simultaneously for all with , .
We condition on these two events in the rest of the proof, which hold with probability . If , then either (1) , or (2) and . In the second case,
This proves the second item.
Finally, for every , the first item implies , and thus . Since , we have , proving the third item.
The following property of exponential variables is widely used in weighted sampling.
Lemma 12 ([35]). Let , let be independent random variables, and set . Let and . Then, we have , , and is independent of .
Let denote the event that Lemma 11 holds. Then . Define
and . Let and .
Lemma 13. Conditioned on , we have for every . Moreover, .
Proof. Fix any for which holds. Conditioned on this , the values are fixed, while remain independent random variables. Applying Lemma 12 with and , we obtain
Moreover, since , .
Lemma 14. The probability that Algorithm 4 fails at line 11 is at most . Conditioned on , if this event does not occur and , Algorithm 4 returns J.
Proof. Let be the number of nodes stored in . Since for every , we have . A Chernoff bound therefore gives .
Now condition on and suppose that . If , then Algorithm 4 processes explicitly in the second pass. If , then Lemma 11 gives , and hence . Thus, was stored in the first pass, and its exact degree is computed in the second pass. Therefore, in both cases Algorithm 4 returns .
We now prove Theorem 10. By Lemma 11, Lemma 13, and Lemma 14, Algorithm 4 fails with probability at most . Conditioned on and no failure, Algorithm 4 outputs with probability . Consequently, for every ,
where the last equality holds since we have assumed that , and and . Thus, Algorithm 4 is a --sampler.
2.5 Removing the Assumption that Is Known
We now explain how to obtain the random samples in the first pass in all of our algorithms without knowing the stream length. Note that after the first pass, is known automatically.
Let denote the required sample size when the current stream length is , and let be a sufficiently large constant. We assign each arriving node an independent rank chosen uniformly from . After processing nodes, we set and store precisely the nodes satisfying , discarding any previously stored nodes that no longer satisfy this condition when the threshold decreases.
For each sample size used in this paper, is sublinear and is decreasing. Hence, after each update, the stored set is exactly . At the end of the first pass, if , the number of stored nodes satisfies and . A Chernoff bound therefore shows that with high probability. We then select the stored nodes with the smallest ranks. These are the smallest-ranked nodes in the entire stream and hence form a uniform sample without replacement.
Moreover, at every time , the expected number of stored nodes is at most . For a sufficiently large constant , a Chernoff bound gives . Note that the size of each sample used in our algorithms is . A union bound over all updates therefore shows that with high probability.
For Algorithms 1 and 2, we apply this construction only to the witness set . For Algorithm 3, we apply this construction for both and . For Algorithm 4, we apply this construction to . The standard concentration bounds for uniform sampling without replacement are no weaker than the corresponding bounds used in all these algorithms. For in Algorithm 4, each node is assigned an independent exponential rank and is stored when , where ; since is decreasing and , the same Chernoff-bound argument preserves the stated space bound with high probability. Thus, the stated guarantees and space bounds are preserved without an additional pass.
3 Lower Bounds
In this section, we give several lower bounds to complement our algorithmic results.
We use to represent the -th unit vector in , and to represent the -dimensional vector of all zeros. Given and , the notation stands for the vector in obtained by concatenating and .
Although we describe the hard instances using high-dimensional vectors, every stream item in our reductions has a succinct -bit representation using only indices and constant-valued coordinates, from which the similarity function can be evaluated directly.
We prove lower bounds by performing reductions from the following well-studied communication problems.
Definition 1 (INDEX). In the INDEX problem, Alice holds an -bit vector , and Bob holds an index . The task is for Alice to send a message to Bob so that Bob can output .
Lemma 15 ([39]). Any randomized algorithm that solves INDEX with probability at least 0.51 needs bits of communication.
Definition 2 (DISJ). In the DISJ problem, Alice holds an -bit vector , and Bob holds an -bit vector . The task is for Alice and Bob to exchange messages so that they output 1 if there exists an index such that , and output 0 otherwise.
Lemma 16 ([4]). Any randomized algorithm that solves DISJ with probability at least 0.51 needs bits of communication.
In the proofs of theorems in this section, we always use to denote an instance of INDEX or DISJ for which the output is 0, and to denote an instance for which the output is 1.
3.1 One-Pass Streaming Algorithms
We show the following lower bounds for one-pass streaming algorithms in the node-arrival model.
Theorem 17. For any constant , any one-pass -approximation algorithm for computing DI on a data stream of length needs bits of space.
Proof. Set and . We perform a reduction from INDEX to DI. The input reduction is as follows: Alice, for each , adds points at location if , or points at location if . Bob, for each , adds a point at location . In total, Alice and Bob create points. We then define the similarity between two points and as follows:
If , then . If , then
We thus have
Therefore, any one-pass -approximation streaming algorithm for DI using bits of space can be used to solve INDEX with bits of communication: Alice simulates on the set of points she has constructed, in any order, and sends the resulting memory configuration to Bob. Bob then continues the simulation on the set of points he has constructed, also in any order, and outputs 1 if 's estimate of DI is at most . By Lemma 15, any such algorithm requires space.
Theorem 18. For any , any one-pass -sampler on a data stream of length needs bits of space.
Proof. We use the hard instance from the proof of Theorem 17 with and . Let be the set of the nodes added by Alice, and let be the event that the sampler outputs a node in .
If , then the total inverse-degree mass of is and , so the target probability of is .
If , then the total inverse-degree mass of is and . Consequently, the target probability of is
Suppose that there is a one-pass -sampler using bits of space, where . Run independent copies of in parallel. Alice runs all copies on her portion of the stream and sends their memory configurations to Bob. Bob then continues all copies on his portion of the stream. He outputs 1 if at least one copy returns a node in , and outputs 0 otherwise. In particular, a failure is treated as not returning a node in .
If , then one copy returns a node in with probability at most . Therefore, by a union bound, when , the probability that the protocol incorrectly outputs 1 is at most .
If , then one copy returns a node in with probability at least
Since copies are independent, the probability that none of them returns a node in is at most .
The protocol therefore solves INDEX with success probability greater than 0.51. Its total communication is bits. By Lemma 15, .
Theorem 19. For any and constant , any one-pass -approximation algorithm for computing on a data stream of length needs bits of space.
Proof. Set and . We perform a reduction from INDEX to . The input reduction is as follows: Alice, for each , adds points at locations if , or points at locations if . Bob, for each , adds a point at location . In total, Alice and Bob create points. We then define the similarity between two points and as follows:
If , then . If , then
Thus, for any constant , we have
Since any one-pass -approximation streaming algorithm for using bits of space can be used to solve INDEX with bits of communication, by Lemma 15, any such algorithm requires space.
Theorem 20. For any and , any one-pass -sampler on a data stream of length needs bits of space.
Proof. We use the same hard instance from the proof of Theorem 19. Choose a constant satisfying , and set .
Let be the set of the nodes added by Alice for coordinates , and let be the event that the sampler outputs a node in .
If , then every node has degree 1. Therefore, the target probability of is
where the last inequality holds for .
If , then the nodes added by Alice for coordinate have degree , the nodes added by Bob have degree , and all nodes in have degree 1. Hence the target probability of is
Suppose that there is a one-pass -sampler using bits of space, where . Run independent copies of in parallel. Alice runs all copies on her portion of the stream and sends their memory configurations to Bob. Bob then continues all copies on his portion of the stream. He outputs 0 if at least one copy returns a node in , and outputs 1 otherwise. A failure is treated as not returning a node in .
If , then one copy returns a node in with probability at least
Since the copies are independent, the probability that none of them returns a node in is at most . Thus, when , the protocol outputs 0 with probability greater than 0.57.
If , then one copy returns a node in with probability at most
Therefore, by a union bound, the probability that the protocol incorrectly outputs 0 is at most .
The protocol therefore solves INDEX with success probability greater than 0.51. Its total communication is bits. By Lemma 15, .
3.2 Multi-Pass Streaming Algorithms
We give the following multi-pass lower bound.
Theorem 21. For any , any -pass -approximation algorithm for computing DI on a data stream of length needs bits of space.
Proof. Set and . We perform a reduction from DISJ to DI. The input reduction is as follows: Alice, for each , adds points at locations if , or points at locations if . Bob, for each , adds points all at location if , or points all at location if . In total, Alice and Bob create points. We then define the similarity between two points and as follows:
If , then
If , then there exists coordinates satisfying and
It follows that
Thus, for any , easy calculations give
Therefore, any -pass -approximation streaming algorithm for DI using bits of space can be used to solve DISJ with bits of communication. By Lemma 16, any such algorithm requires space.
Theorem 22. For any , any -pass -sampler on a data stream of length needs bits of space.
Proof. We use the hard instance from the proof of Theorem 21, but choose , so the stream contains nodes.
Let be the set of Alice's nodes belonging to coordinates for which , and let be the event that the sampler outputs a node in . If , then and never occurs.
If , then there exists coordinates satisfying and the total inverse-degree mass of is rt=4rk, while
Hence the probability of is .
Suppose that there is an -pass -sampler using bits of space, where . Run independent copies of in parallel. Alice and Bob simulate these copies by exchanging their memory configurations after their respective portions of each pass. After the samplers terminate, they use additional bits to determine whether any copy returned a node in . They output 1 if and only if this occurs. A failure is treated as not returning a node in .
If , then , so the protocol always outputs 0 and is therefore always correct.
If , then one copy returns a node in with probability at least
Since copies are independent, the probability that none of them returns a node in is at most .
The protocol therefore solves DISJ with success probability greater than 0.51. The total communication is bits. By Lemma 16, .
Theorem 23. For any and , any -pass -approximation algorithm for computing on a data stream of length needs bits of space.
Proof. Let . Set
We perform a reduction from DISJ to . The input reduction is as follows: Alice, for each , adds points at locations if , or points at locations if . Bob, for each , adds points at locations if , or points at locations if . In total, Alice and Bob create points. We then define the similarity between two points and as follows:
If DISJ , then . If DISJ , then there exists coordinates satisfying and
where we apply the inequality for any and . Thus, for any , easy calculations give
Therefore, any -pass -approximation streaming algorithm for using bits of space can be used to solve DISJ with bits of communication. By Lemma 16, any such algorithm requires space.
Theorem 24. For any and , any -pass -sampler on a data stream of length needs bits of space.
Proof. We use the same hard instance from the proof of Theorem 23, but choose . The resulting stream contains nodes.
Let be the set of Alice's nodes belonging to coordinates for which , and let be the event that the sampler outputs a node in . If , then , and hence never occurs.
Suppose that , and let be the number of coordinates satisfying . For every such coordinate, the corresponding Alice nodes and Bob nodes have degree , while all other nodes have degree 1. Therefore, the total mass of is , and . Hence the target probability of is
Suppose that there is an -pass -sampler using bits of space, where . Run independent copies of in parallel. Alice and Bob simulate these copies by exchanging their memory configurations after their respective portions of each pass. After the samplers terminate, they use additional bits to determine whether any copy returned a node in . They output 1 if and only if this occurs. A failure is treated as not returning a node in .
If , then , so the protocol always outputs 0 and is therefore always correct.
If , then one copy returns a node in with probability at least
Since copies are independent, the probability that none of them returns a node in is at most .
The protocol therefore solves DISJ with success probability greater than 0.51. The total communication is bits. By Lemma 16, .
4 Concluding Remarks
In this work, we studied a set of statistical problems defined on similarity graphs in the node-arrival data stream model. Several questions remain open. For example, while our upper and lower bounds match in terms of , they still differ with respect to ; can these bounds be made tight? It would also be interesting to study other statistical problems defined on similarity graphs in the node-arrival streams.
References
[1] Noga Alon, Yossi Matias, and Mario Szegedy. The space complexity of approximating the frequency moments. J. Comput. Syst. Sci., 58(1):137–147, 1999.
[2] Alexandr Andoni. High frequency moments via max-stability. In ICASSP, pages 6364–6368, 2017.
[3] Alexandr Andoni, Robert Krauthgamer, and Krzysztof Onak. Streaming algorithms via precision sampling. In FOCS, pages 363–372, 2011.
[4] Ziv Bar-Yossef, T. S. Jayram, Ravi Kumar, and D. Sivakumar. An information statistics approach to data stream and communication complexity. J. Comput. Syst. Sci., 68(4):702–732, 2004.
[5] Ziv Bar-Yossef, T. S. Jayram, Ravi Kumar, D. Sivakumar, and Luca Trevisan. Counting distinct elements in a data stream. In RANDOM, pages 1–10, 2002.
[6] Kevin Beyer, Peter J Haas, Berthold Reinwald, Yannis Sismanis, and Rainer Gemulla. On synopses for distinct-value estimation under multiset operations. In SIGMOD, pages 199–210, 2007.
[7] Lakshminath Bhuvanagiri, Sumit Ganguly, Deepanjan Kesh, and Chandan Saha. Simpler algorithm for estimating frequency moments of data streams. In SODA, pages 708–713, 2006.
[8] Mark Braverman and Or Zamir. Optimality of frequency moment estimation. In STOC, pages 360–370, 2025.
[9] Vladimir Braverman and Rafail Ostrovsky. Recursive sketching for frequency moments. CoRR, abs/1011.2571, 2010.
[10] Sergio Cabello and Pablo Pérez-Lantero. Interval selection in the streaming model. Theor. Comput. Sci., 702:77–96, 2017.
[11] Yair Caro. New results on the independence number. Technical report, Tel Aviv University, 1979.
[12] Amit Chakrabarti, Subhash Khot, and Xiaodong Sun. Near-optimal lower bounds on the multi-party communication complexity of set disjointness. In CCC, pages 107–117, 2003.
[13] Sourav Chakraborty, N. V. Vinodchandran, and Kuldeep S. Meel. Distinct elements in streams: An algorithm for the (text) book. In ESA, pages 34:1–34:6, 2022.
[14] Moses Charikar, Kevin C. Chen, and Martin Farach-Colton. Finding frequent items in data streams. In ICALP, pages 693–703, 2002.
[15] Di Chen and Qin Zhang. Streaming algorithms for robust distinct elements. In SIGMOD, pages 1433–1447, 2016.
[16] Jiecao Chen and Qin Zhang. Distinct sampling on streaming data with near-duplicates. In PODS, pages 369–382, 2018.
[17] Graham Cormode, Jacques Dark, and Christian Konrad. Approximating the caro-wei bound for independent sets in graph streams. In ISCO, pages 101–114, 2018.
[18] Graham Cormode, Jacques Dark, and Christian Konrad. Independent sets in vertex-arrival streams. In ICALP, pages 45:1–45:14, 2019.
[19] Graham Cormode and Donatella Firmani. A unifying framework for 0-sampling algorithms. Distributed Parallel Databases, 32(3):315–335, 2014.
[20] Graham Cormode and S. Muthukrishnan. An improved data stream summary: the count-min sketch and its applications. J. Algorithms, 55(1):58–75, 2005.
[21] Graham Cormode, S. Muthukrishnan, and Irina Rozenbaum. Summarizing and mining inverse distributions on data streams via dynamic inverse sampling. In VLDB, pages 25–36, 2005.
[22] Marianne Durand and Philippe Flajolet. Loglog counting of large cardinalities. In ESA, pages 605–617. 2003.
[23] Talya Eden, Dana Ron, and C. Seshadhri. Sublinear time estimation of degree distribution moments: The degeneracy connection. In ICALP, pages 7:1–7:13, 2017.
[24] Yuval Emek, Magnús M. Halldórsson, and Adi Rosén. Space-constrained interval selection. ACM Trans. Algorithms, 12(4):51:1–51:32, 2016.
[25] Uriel Feige. On sums of independent random variables with unbounded variance, and estimating the average degree in a graph. In STOC, pages 594–603, 2004.
[26] Philippe Flajolet and G. Nigel Martin. Probabilistic counting algorithms for data base applications. J. Comput. Syst. Sci., 31(2):182–209, 1985.
[27] Gereon Frahling, Piotr Indyk, and Christian Sohler. Sampling in dynamic data streams and applications. In Joseph S. B. Mitchell and Günter Rote, editors, SoCG, pages 142–149, 2005.
[28] Sumit Ganguly. Counting distinct items over update streams. Theoretical Computer Science, 378(3):211–222, 2007.
[29] Sumit Ganguly. Polynomial estimators for high frequency moments. CoRR, abs/1104.4552, 2011.
[30] Sumit Ganguly. A lower bound for estimating high moments of a data stream. CoRR, abs/1201.0253, 2012.
[31] Sumit Ganguly and David P. Woodruff. High probability frequency moment sketches. In ICALP, pages 58:1–58:15, 2018.
[32] Oded Goldreich and Dana Ron. Approximating average parameters of graphs. Random Struct. Algorithms, 32(4):473–493, 2008.
[33] Mira Gonen, Dana Ron, and Yuval Shavitt. Counting stars and other small subgraphs in sublinear-time. SIAM J. Discret. Math., 25(3):1365–1411, 2011.
[34] Piotr Indyk and David P. Woodruff. Optimal approximations of the frequency moments of data streams. In STOC, pages 202–208, 2005.
[35] Rajesh Jayaram and David P. Woodruff. Perfect lp sampling in a data stream. In FOCS, pages 544–555, 2018.
[36] Hossein Jowhari, Mert Saglam, and Gábor Tardos. Tight bounds for lp samplers, finding duplicates in streams, and related problems. In PODS, pages 49–58, 2011.
[37] Daniel M. Kane, Jelani Nelson, and David P. Woodruff. On the exact space complexity of sketching and streaming small norms. In SODA, pages 1161–1178, 2010.
[38] Daniel M. Kane, Jelani Nelson, and David P. Woodruff. An optimal algorithm for the distinct elements problem. In PODS, pages 41–52, 2010.
[39] Eyal Kushilevitz and Noam Nisan. Communication Complexity. Cambridge University Press, 1996.
[40] Yi Li and David P. Woodruff. A tight lower bound for high frequency moment estimation with small error. In APPROX-RANDOM, pages 623–638, 2013.
[41] Kaiwen Liu, Seba Daniela Villalobos, and Qin Zhang. Estimating correlation clustering cost in node-arrival stream. In ICML, 2026.
[42] Kaiwen Liu and Qin Zhang. Frequency moments in noisy streaming and distributed data under mismatch ambiguity. Proc. ACM Manag. Data, 4(2):105:1–105:24, 2026.
[43] Andrew McGregor. Graph stream algorithms: a survey. SIGMOD Rec., 43(1):9–20, 2014.
[44] Ahmed Metwally, Divyakant Agrawal, and Amr El Abbadi. Efficient computation of frequent and top-k elements in data streams. In ICDT, pages 398–412, 2005.
[45] Jayadev Misra and David Gries. Finding repeated elements. Sci. Comput. Program., 2(2):143–152, 1982.
[46] Morteza Monemizadeh and David P. Woodruff. 1-pass relative-error lp-sampling with applications. In SODA, pages 1143–1160, 2010.
[47] Noam Nisan. Psuedorandom generators for space-bounded computation. In STOC, pages 204–212, 1990.
[48] Victor K. Wei. A lower bound on the stability number of a simple graph. Technical report, Bell Laboratories, 1981.
[49] David P. Woodruff. Optimal space lower bounds for all frequency moments. In SODA, pages 167–175, 2004.
[50] Qin Zhang. Robust statistical analysis on streaming data with near-duplicates in general metric spaces. Proc. ACM Manag. Data, 3(2):111:1–111:25, 2025.