arXiv:2609.04505cs.DSSep 2026Cited by 2 papers on PaperVantage

Manuscript Offprint

arXiv:2609.04505

Statistics of Similarity Graphs in Node-Arrival Streams

Kaiwen Liu, Qin Zhang

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 σ=(σ1,…,σn)∈Un\sigma = (\sigma_1, \ldots, \sigma_n) \in U^n denote the data stream, and let f:U×U→[0,1]f: U \times U \to [0,1] be a symmetric similarity function satisfying f(x,x)=1f(x,x) = 1 for all x∈Ux \in U. The similarity graph of σ\sigma is the complete weighted graph GσG^\sigma on the node set [n][n], with edge weight function w(i,j)=f(σi,σj)w(i,j) = f(\sigma_i, \sigma_j) for all i,j∈[n]i,j \in [n]. Thus, each edge has a weight in [0,1][0,1], with every node ii having a self-loop of weight w(i,i)=1w(i,i) = 1. For each i∈[n]i \in [n], let

di=∑j∈[n]w(i,j)=∑j∈[n]f(σi,σj),d_i = \sum_{j \in [n]} w(i,j) = \sum_{j \in [n]} f(\sigma_i, \sigma_j),

which can be viewed as the similarity-weighted frequency of σi\sigma_{i}.

In this paper, we study the following statistics of the similarity graph:

  1. Mp(σ)=∑i∈[n]dip(p>0)M_{p}(\sigma) = \sum_{i \in [n]} d_{i}^{p} (p > 0): degree moments of GσG^{\sigma}. When f is the equality function, Mp(σ)M_{p}(\sigma) degenerates to the classical (p+1)(p+1)-th frequency moment Fp+1(σ)F_{p+1}(\sigma). When f is Boolean, the quantity M1(σ)M_{1}(\sigma) corresponds to the size of the self-similarity join of the set σ\sigma under f.

  2. DI(σ)=∑i∈[n]di−1\mathrm{DI}(\sigma) = \sum_{i \in [n]} d_i^{-1}: diversity index of GσG^\sigma. DI(σ)\mathrm{DI}(\sigma) characterizes the “level of diversity” of the set σ\sigma under the similarity function ff. When ff is the equality function, DI(σ)\mathrm{DI}(\sigma) degenerates to the number of distinct elements in σ\sigma. When ff 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.

  3. LMpL_{M_{p}}-sampler: degree-moment sampler on GσG^{\sigma} that samples nodes with probability proportional to the pp-th power of their degrees; it outputs node ii with probability dip/Mp(σ)d_{i}^{p}/M_{p}(\sigma). When ff is the equality function, LMpL_{M_{p}}-sampler degenerates to the classical ℓp+1\ell_{p+1}-sampler.

  4. LDIL_{\mathrm{DI}}-sampler: diversity sampler on GσG^{\sigma} that samples nodes with probability proportional to the inverse of their degrees; it outputs node ii with probability di−1/DI(σ)d_{i}^{-1}/\mathrm{DI}(\sigma). When ff is the equality function, LDIL_{\mathrm{DI}}-sampler degenerates to the classical ℓ0\ell_{0}-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 σ=(σ1,…,σn)∈Un\sigma = (\sigma_1, \ldots, \sigma_n) \in U^n, where each item corresponds to a node of GσG^\sigma. We are also given access to a similarity function f:U×U→[0,1]f : U \times U \to [0,1]. The weights of GσG^\sigma are not provided explicitly. Instead, the weight between two nodes is computed on demand by evaluating ff, 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 pp is a constant throughout the paper. When σ\sigma is clear from the context, we simply write Mp(σ)M_p(\sigma), DI(σ)\mathrm{DI}(\sigma), LMp(σ)L_{M_p}(\sigma) and LDI(σ)L_{\mathrm{DI}}(\sigma) as MpM_p, DI\mathrm{DI}, LMpL_{M_p} and LDIL_{\mathrm{DI}}.

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 ff, and each arithmetic quantity maintained by our algorithms can be represented using O(1)O(1) words. If each item requires bb bits to represent, then all of our upper bounds, when stated in bits, incur an additional multiplicative factor of bb. Our lower bounds are stated in bits and use only Boolean similarity functions.

We regard each stream item as a distinct node. Thus, node i∈[n]i \in [n] is represented by the pair (i,σi)(i, \sigma_i). When there is no ambiguity, we use σi\sigma_i to refer to node ii as well as its associated item value.

For any ϵ∈(0,1)\epsilon \in (0,1), we say X~\tilde{X} is a (1+ϵ,δ)(1+\epsilon,\delta)-approximation of XX if (1−ϵ)X≤X~≤(1+ϵ)X(1-\epsilon)X \leq \tilde{X} \leq (1+\epsilon)X with probability at least (1−δ)(1-\delta). For some lower bounds, we are able to prove for larger approximation ratios. For any α≥1\alpha \geq 1, we say X~\tilde{X} is an (α,δ)(\alpha,\delta)-approximation of XX if X/α≤X~≤αXX/\alpha \leq \tilde{X} \leq \alpha X with probability at least (1−δ)(1-\delta).

We use the notation x=a±bx = a \pm b to indicate that xx lies within the interval [a−b,a+b][a-b, a+b]. For LDIL_{\mathrm{DI}}-sampling and LMpL_{M_p}-sampling, we slightly relax the sampling criterion by allowing a relative error ϵ\epsilon. A (1+ϵ,δ)−LDI(1+\epsilon, \delta)-L_{\mathrm{DI}}-sampler (resp. LMpL_{M_p}-sampler) on GσG^\sigma fails with probability at most δ\delta and conditioned on no failure, outputs node ii with probability pi=(1±ϵ)di−1DI(σ)p_i = (1 \pm \epsilon) \frac{d_i^{-1}}{\mathrm{DI}(\sigma)} (resp. pi=(1±ϵ)dipMp(σ)p_i = (1 \pm \epsilon) \frac{d_i^p}{M_p(\sigma)}).

Our Results. We present the following algorithmic results in Section 2.

  • For any ϵ∈(0,1)\epsilon \in (0,1), a (1+ϵ,o(1))(1+\epsilon, o(1))-approximation algorithm for diversity index DI uses O(1ϵ2nlog⁡n)O\left(\frac{1}{\epsilon^2} \sqrt{n} \log n\right) words of space and three passes.

  • For any ϵ∈(0,1)\epsilon \in (0,1), a (1+ϵ,o(1))(1+\epsilon, o(1))-LDIL_{\mathrm{DI}}-sampler uses O(1ϵ2nlog⁡n)O\left(\frac{1}{\epsilon^2} \sqrt{n} \log n\right) words of space and three passes.

  • For any ϵ∈(0,1)\epsilon \in (0,1) and any p>0p > 0, a (1+ϵ,0.01)(1+\epsilon, 0.01)-approximation algorithm for degree moment MpM_p uses O(1ϵ2n1−1p+1log⁡n)O\left(\frac{1}{\epsilon^2} n^{1-\frac{1}{p+1}} \log n\right) words of space and two passes.

  • For any ϵ∈(0,1)\epsilon \in (0,1) and any p>0p > 0, a (1+ϵ,o(1))(1+\epsilon, o(1))-LMpL_{M_p}-sampler uses O(1ϵ2n1−1p+1log⁡n)O\left(\frac{1}{\epsilon^2} n^{1-\frac{1}{p+1}} \log n\right) words of space and two passes.

We supplement the results above with the following lower bounds in Section 3.

  • Any one-pass (O(1),0.49)(O(1), 0.49)-approximation algorithm for diversity index DI needs Ω(n)\Omega(n) bits of space. For any ϵ∈(0,0.9)\epsilon \in (0, 0.9), any O(1)O(1)-pass (1+ϵ,0.49)(1+\epsilon, 0.49)-approximation algorithm for DI needs Ω(min⁡(nϵ,n))\Omega\left(\min\left(\sqrt{\frac{n}{\epsilon}}, n\right)\right) bits of space.

  • For any ϵ∈(0,0.9)\epsilon \in (0, 0.9), any one-pass (1+ϵ,0.49)(1+\epsilon, 0.49)-LDIL_{\mathrm{DI}}-sampler needs Ω(n)\Omega(n) bits of space, and any O(1)O(1)-pass (1+ϵ,0.49)(1+\epsilon, 0.49)-LDIL_{\mathrm{DI}}-sampler needs Ω(n)\Omega(\sqrt{n}) bits of space.

  • For any p>0p > 0, any one-pass (O(1),0.49)(O(1), 0.49)-approximation algorithm for MpM_p needs Ω(n)\Omega(n) bits of space. For any ϵ∈(0,0.9)\epsilon \in (0, 0.9) and p>0p > 0, any O(1)O(1)-pass (1+ϵ,0.49)(1+\epsilon, 0.49)-approximation algorithm for MpM_p needs Ω(min⁡(ϵ−1p+1n1−1p+1,n))\Omega\left(\min\left(\epsilon^{-\frac{1}{p+1}} n^{1-\frac{1}{p+1}}, n\right)\right) bits of space.

  • For any ϵ∈(0,0.9)\epsilon \in (0, 0.9) and p>0p > 0, any one-pass (1+ϵ,0.49)(1+\epsilon, 0.49)-LMpL_{M_p}-sampler needs Ω(n)\Omega(n) bits of space, and any O(1)O(1)-pass (1+ϵ,0.49)(1+\epsilon, 0.49)-LMpL_{M_p}-sampler needs Ω(n1−1p+1)\Omega\left(n^{1-\frac{1}{p+1}}\right) 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 nn, up to logarithmic factors.

References (41)