Dynamic Graph Stream Algorithms in o(n) Space

In this paper we study graph problems in the dynamic streaming model, where the input is defined by a sequence of edge insertions and deletions. As many natural problems require \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\varOmega (n)$$\end{document}Ω(n) space, where n is the number of vertices, existing works mainly focused on designing \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$${O}(n\cdot \mathrm {poly}\log n)$$\end{document}O(n·polylogn) space algorithms. Although sublinear in the number of edges for dense graphs, it could still be too large for many applications (e.g., n is huge or the graph is sparse). In this work, we give single-pass algorithms beating this space barrier for two classes of problems. We present o(n) space algorithms for estimating the number of connected components with additive error \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\varepsilon n$$\end{document}εn of a general graph and \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$(1+\varepsilon )$$\end{document}(1+ε)-approximating the weight of the minimum spanning tree of a connected graph with bounded edge weights, for any small constant \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\varepsilon >0$$\end{document}ε>0. The latter improves upon the previous \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$O(n\cdot \mathrm {poly}\log n)$$\end{document}O(n·polylogn) space algorithm given by Ahn et al. (SODA 2012) for the same class of graphs. We initiate the study of approximate graph property testing in the dynamic streaming model, where we want to distinguish graphs satisfying the property from graphs that are \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\varepsilon $$\end{document}ε-far from having the property. We consider the problem of testing k-edge connectivity, k-vertex connectivity, cycle-freeness and bipartiteness (of planar graphs), for which, we provide algorithms using roughly \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$${O}(n^{1-\varepsilon }\cdot \mathrm {poly}\log n)$$\end{document}O(n1-ε·polylogn) space, which is o(n) for any constant \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\varepsilon $$\end{document}ε. To complement our algorithms, we present \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\varOmega (n^{1-O(\varepsilon )})$$\end{document}Ω(n1-O(ε)) space lower bounds for these problems, which show that such a dependence on \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\varepsilon $$\end{document}ε is necessary.


Introduction
Graphs or networks are a natural way to describe structural information.For example, users of Facebook and the acquaintance relations among them form a social network, the proteins together with interactions between them define a biological network, and web-pages and hyperlinks give rise to a huge web graph.Due to the rapid development of information technology, many such graphs become extremely large, and are constantly changing, which poses great challenges for analyzing their structures.Over the last decade, the data stream model [Mut05] has proven to be successful in dealing with big data.In this model, the algorithm should make only one pass (or a few passes) over the stream, and use sublinear working space.The time required to output the final answer and process each element is also important.There is a growing body of work studying graph problems over data streams.Graph streams were first considered by Henzinger et al. [HRR98], and later have been extensively studied in the insertion-only model (eg., [FKM + 05, FKM + 08, Mut05]), where there is no edge deletion in the stream.Recently, starting from the seminal works of Ahn, Guha and McGregor [AGM12a,AGM12b], the interest has shifted to the dynamic streaming model, where the edges can be both inserted and deleted (see eg., [KLMS14, KW14, ACG + 15, AKLY16, CCE + 16, CCHM15, BS15, Kon15, BHNT15, MTVV15, EHW15, GMT15]).In this setting, most algorithms designed are linear sketch-based, which is also an effective technique for processing distributed graphs.For more information about graph streaming algorithms see the recent survey by McGregor [McG14].
For graph streams, both insertion-only and dynamic, the research in the past has mostly focused on the semi-streaming model, in which the algorithms are allowed to use Õ(n) space, where n is the number vertices in the graph.(For notational convenience, we will use Õ(g) and Ω(g) to hide poly log(g) factors.)The reason behind this is that even in the insertion-only model, many natural graph problems require Ω(n) space (e.g.testing if the graph is connected [FKM + 08]).Note that the allowed space in semi-streaming model is sublinear in the input size as the number of edges of the graph might be as large as Ω(n 2 ).However, in many real applications n is huge and the input graph is already very sparse, an Õ(n) algorithm might be even worse than just storing all the edges.From this perspective, one may naturally ask the question which kind of problems can be solved with even less space, i.e., o(n) space.
To the best of our knowledge, very few results are known in this direction.Chitnis et al. [CCHM15] and Fafianie and Kratsch [FK14] introduced parameterized graph stream algorithms which may only use o(n) space with some promise of the size of the solution.This parameterized setting has been further investigated in [CCE + 16].In addition, it has been shown that the size of the maximum matching can be approximated within constant factor in Õ(n 4/5 ) space for graphs with bounded arboricity [EHL + 15, CCE + 16, BS15].
In this paper, we study two classes of graph problems that admit single-pass o(n) space algorithms in the dynamic streaming model.The first class contains the problems of estimating the number of connected components and the weight of minimum spanning tree (MST).We show that one can estimate the number of connected components within an additive error of εn with o(n) space and post-processing time, for any constant ε > 0. We also present an algorithm to (1 + ε)-approximate the weight of MST with o(n) space and post-processing time for connected graphs with bounded edge weights, which improves the best known algorithm with Õ(n) space in the same setting given by Ahn et al. [AGM12a].It is worthy noting that the problem of estimating the number of connected components within small multiplicative error requires Ω(n) space, as it is generally harder than the problem of (exactly) testing graph connectivity; and that estimating the weight of MST for graphs with arbitrarily large edge weights (e.g., Ω(log n)) requires Ω(n) space (see Theorem 5.3).Previously these two problems have been studied in the framework of sublinear time algorithms (see eg. [CRT05,RS11]).
The second class consists of problems that are relaxations of deciding graph properties.Given a huge graph, it is very useful to know whether the graph has some predetermined property, such as k-connectivity, bipartiteness, cycle-freeness and etc., which provide valuable information about the graph.However, besides the requirement of Ω(n) space, exactly testing of these properties sometimes is a too strong requirement for analyzing highly dynamic graphs, since the answer may change in the next second due to an insertion or deletion of a single edge.In this paper, we initiate the study of approximate graph property testing in the dynamic streaming model: we want to test whether a graph satisfies some property or one has to modify a small constant fraction of edges to make it have the property.This notion of approximation is adapted from the framework of property testing [GGR98, GR02, PR02], and a large number of existing literatures have given efficient testing algorithms (called testers) for many properties under different query models (see surveys [Gol11,Ron10]).We show that some fundamental properties can be tested in both o(n) space and postprocessing time in the dynamic streaming model and we also present close lower bounds for these problems which hold even in the insertion-only model.We remark that McGregor [McG14] also suggested to study the (approximate) property testers in graph streaming model, and asked whether more space-efficient algorithms exist for these problems, and we thus give affirmative answer to this question.

Our results
Now we formally state our main results.Our results regarding estimating the number of connected components and the MST weight are as follows.
• Estimating the number of connected components.We present a dynamic streaming algorithm that estimates the number of connected components within additive error εn in Õ(n 1−ε+ε q+1 ) space and post-processing time for any constant q ≥ 1.We note that a lower bound of Ω(n 1−O(ε) ) for this problem follows from the work [VY11].
• Estimating the weight of minimum spanning tree (MST).In this problem, we want to estimate the weight of the MST of a graph with edge weights in the set {1, 2, • • • , W }. We give a dynamic streaming algorithm that computes a (1 + ε)-approximation of the MST weight and uses space and post-processing time Õ(W n ) for any constant t ≥ 1.By an argument in [CRT05], the result can be extended to non-integral weights, as long as the ratio between the largest and the smallest weight is bounded.A space lower bound of Ω(n 1− 4ε W −1 ) is shown for this problem.
We also present approximate testing algorithms for a number of fundamental graph properties.Before stating the performance of these algorithms, we first introduce some definitions.Given a graph property Π, an m-edge graph G is called ε-far from having Π if one has to modify more than εm edges of G to get a graph G satisfying Π.This distance definition is adapted from [PR02] and is most suitable for general graphs where neither edge density nor maximum degree is restricted.We call an algorithm a (dynamic) streaming tester for Π, if it makes a single-pass over a stream of edge insertions and deletions, with probability at least 2/3, accepts any graph satisfying Π, and rejects any graph that is ε-far from having Π.
We give sketch-based streaming testers for properties of being connected, k-edge connected, kvertex connected, cycle-freeness and bipartite (for planar graphs).The performance of our testers are summarized in Table 1.We stress that most of our testers have (asymptotically) the same post-processing time as the space they used except for testing k-edge connectivity when k ≥ Ω(n ε/(1+ε) ) and k-vertex connectivity when k ≥ Ω(n ε/(4+ε) ).

Space
Space lower bound Õ Ω Connectivity

Our techniques
To estimate the number of connected components with small additive error εn, we note that it is sufficient to estimate the number scc(G) of connected components of small size (i.e., O(1/ε)), since the number of components of size larger than this is at most O(εn) (see also [CRT05]).To estimate scc(G), the following vertex sampling framework is used: we sample a sufficient large set of vertices S by sampling each vertex in G with some probability p, and then use the statistics of the sampled connected components of the original graph to estimate scc(G).For any small connected component C in G, it is likely that all the vertices in C will be sampled out.Conditioned on this, we add 1/p |C| to our final estimator, which is the reciprocal of the probability that C is entirely sampled out.Now the task is then to identify which subsets of S are connected components in the original graph.A trivial way is to check all subsets of S, which takes too much time.A more efficient way is to only check all the connected components in G[S], since a sampled component of G must also form a component in G[S].We carefully use a set of linear sketches to do this.More specifically, we first recover all connected components in G[S] by invoking a sketch-based streaming algorithm given in [AGM12a], which only needs space near-linear in |S|.Then we use (different) linear sketches to check if any of these components is indeed a connected component of the original graph.We remark that the first set of linear sketches of a vertex v sketch its neighborhood information in G[S], while the second set sketch its neighborhood information in G. Our o(n) space streaming algorithm for (1+ε)-approximating the weight of MST follows via a connection between the number of connected components and the weight of MST established in [CRT05].
To give testers for some graph property Π in dynamic streaming model, we start from the observation that if a graph G is far from having Π, then typically, there exist many small disjoint subgraphs, each of which is a witness that the graph G does not satisfy Π. (For example, if Π is connectivity, then there exists at least Ω(εm) connected components of size at most O(1/ε) in a graph that is ε-far from being connected.)This implies that by sampling a sufficient large set of vertices, with high probability, one of such subgraphs will be entirely sampled.Checking which vertices form a witness of the original graph can then be done by using the aforementioned framework.Different sketches will be used for testing different properties.
To prove lower bounds for our studied problems, we give reductions from Boolen Hidden Hypermatching (BHH) problem that was studied in [VY11].Our reductions share similarity with the reduction in [VY11] to the cycle-counting problem and the reductions in [KKS15,KK15] to the approximate max-cut problem.

Related work
Ahn et al. [AGM12a] initiated the study of graph sketches, and gave dynamic semi-streaming algorithms for computing a spanning forest (which can be used to count the exact number of connected components), and (1+ε)-approximate the weight of MST.They also proposed algorithms to exactly testing of a set of properties, including testing connectivity, k-edge connectivity, and bipartiteness.Recently, Guha et al. gave dynamic streaming algorithms for exactly testing of kvertex connectivity [GMT15].All these algorithms use Õ(n) space ( Õ(kn) for k-connectivity).On the other hand, the randomized space lower bounds for these exact testing problems were known to be Ω(n) in the insertion-only model [FKM + 05, FKM + 08].Recently, Sun and Woodruff improved these lower bounds to Ω(n log n) [SW15].Verbin and Yu [VY11] proved a lower bound for cyclecounting, which implied a lower bound of Ω(n 1−O(ε) ) for estimating the number of components.
In the random order insertion-only model Kapralov et al. [KKS14] gave a one pass streaming algorithm that estimates the maximum matching size with polylogarithmic approximation ratio in polylogarithmic space.Although sublinear in n, the model considered is very different from ours.
Sublinear time algorithms for estimating the number of connected component and the weight of MST were first given by Chazelle et al. [CRT05].Later these two problems have been further considered in geometric settings [CEF + 05, CS09, FIS05].In particular, Frahling et al. studied the problem of (1 + ε)-approximating the weight of MST in dynamic geometric data stream [FIS05].
There has been a rich line of work on graph property testing in the query model (see surveys [Ron10,Gol11]) and the goal there is to design fast algorithms that make as few queries as possible.The query models that are mostly related to ours are bounded degree model and general graph model.In particular, our definition of ε-far is adapted from the general graph model.Goldreich and Ron [GR02] initiated the study of property testers in bounded degree graph model, and gave testers for connectivity, k-edge connectivity, 2, 3-vertex connectivity, cycle-freeness, Eulerianity.Testing k-vertex connectivity in bounded degree graphs for arbitrary constant k was given in [YI08].These testers have later been generalized to general graph model [PR02,OR11].Testing bipartiteness in planar graphs was studied in [CMOS11].
After having submitted the paper, we became aware that Hossein Jowhari [Jow] has independently studied the problem of estimating the number of connected components and provided similar results as ours, while he did not consider the streaming property testers considered here.

Notations
We use [n] = {1, • • • , n} to denote the vertex set of the graph G defined by the stream, and let m denote the number of edges of G.For an undirected graph G For each vertex i, we define two vectors ∆ i ∈ {−1, 0, 1} ( n 2 ) and Λ i ∈ {0, 1} n to encode the neighborhood information of i as follows: By simple induction arguments, it is easy to prove that for any vertex set C ⊂ V , the nonzero entries in the vector ∆ C := i∈C ∆ i corresponds to the edges between C and its complement V \ C. The nonzero entries in i∈C Λ i corresponds exactly to vertices in C ∪ Γ(C).

Linear sketches
Linear sketch (or sketch for short) is a powerful tool widely used in the streaming model and other areas.Given a large vector x ∈ R n , we want to construct a small sketch L(x), from which certain properties of x can be recovered.We call L a linear sketch if L(x + y) = L(x) + L(y) for all x, y, and this additive property make it trivial to implement linear sketches in the dynamic streaming model.As in the previous works, we will use linear sketches as our main tool.
AGM sketch We will use a dynamic streaming algorithm for constructing a spanning forest of a graph by Ahn, Guha and McGregor [AGM12a], which is summarized as follows.
Theorem 2.1 (AGM sketch [AGM12a]).There exists a single-pass sketch-based dynamic streaming algorithm that uses O(n log 3 n) space, and recovers a spanning forest of the graph with probability 0.99.The recovery time of the algorithm is Õ(n), and the update time is poly log n.

AMS sketch
To check whether the input vector x is 0 or not, one can simply maintain a constant approximation of its second frequency moment, that is F 2 (x) := i x 2 i , which can be done in O(log n) space by using the classical AMS sketch that was introduced by Alon, Matias and Szegedy [AMS96].
Exact k-sparse recovery We call a vector k-sparse if |supp(x)| ≤ k.Given a non-zero vector x ∈ R n , the goal here is to recover x if x is k-sparse, otherwise outputs Fail.We have the following result from [Pri11].

Lemma 2.2 ([Pri11]
).There exists an O(k log n log k δ −1 ) space sketch-based algorithm that takes as input a non-zero vector x ∈ R n , and with probability 1 − δ, recovers x if x is k-sparse, otherwise outputs Fail.The update time is O(poly log n) and the recovery time is O(k • poly log n).

Estimating the number of connected components and MST weight
In this section, we present and analyze our algorithms for estimating the number of the connected components in a graph and (1 + ε)-approximating the weight of the MST.

Estimating the number of connected components
Our first observation is that, to estimate the number of connected components within additive error εn, we can simply ignore all the large components (see also [CRT05]).In particular, the number of components of size larger than Ω(1/ε) is at most O(εn).Thus it will be sufficient to estimate the number of components of small size, for which we have the following theorem.
Theorem 3.1.For any constant t ≥ 1, there exists a one-pass dynamic streaming algorithm that uses O(e t n 1−ε • poly log n) space and post-processing time to estimates the number of connected components of size at most 1/ε within an additive error ε t n.The update time is O(poly log n).
By invoking Theorem 3.1 with parameter ε = (1 − ε q )ε and t = (q + 1), we get an estimator for the number of connected components of size smaller than 1/ε within additive error at most ε q+1 n.Since the number of components of size at least 1/ε is at most ε n = εn − ε 1+q n, the estimator also approximates the total number of connected components within additive error at most εn.The space of the algorithm is Õ(e q+1 n 1−ε+ε q+1 ), and we have the following result.
Theorem 3.2.Let q ≥ 1 be a constant.There exists a one-pass dynamic streaming algorithm that with constant success probability, estimates the number of connected components of a graph within an additive error εn in O(e q+1 n 1−ε+ε q+1 • poly log n) space and post-processing time.Now we give the proof of Theorem 3.1.Recall that the vectors ∆ C encode the information of the number of edges between C and V \ C.
Proof of Theorem 3.1.Let scc(G) denote the number of connected components of size at most 1/ε in G. Our algorithm for estimating scc(G) is as follows.We first sample each vertex with probability p := (ε 2t n/16) −ε .Let S be the set of sampled vertices.We then use the AGM sketch from Theorem 2.1 to maintain a spanning forest F of the subgraph induced by S. Then for each component C in F , we test whether C is actually a connected component in G by testing whether the vector ∆ C := v∈C ∆ v is 0, which can be done by the AMS sketch.If ∆ C = 0, we set X C = 1, otherwise set X C = 0. Our estimator is then defined as C X C p |C| , where C ranges over all components of F with size at most 1 ε .See Algorithm 1 for the details.
Note that the algorithm samples at most 16np = O(ε −2tε • n 1−ε ) vertices and we maintained an AGM sketch on G[S] and an AMS sketch for each sampled vertex, which imply that the space complexity of the algorithm is O(ε −2tε n 1−ε • poly log n).By simple calculus, for any ε, it holds that ε −2ε ≤ e 2/e < e, so the space is at most Õ(e t n 1−ε ).The post-processing time is near linear in the space, and the update time is O(poly log n).
Now we prove the correctness of the above algorithm.First we note that the expected number of sampled vertices in Step (1) is np, and thus by Markov inequality, the probability that more than 16np vertices are sampled is at most 1 16 .Also note that with probability at least 1 − 1 16 , the AGM sketch returns a true spanning forest of G[S].In addition, since the number of components in F is at most n, we will query the AMS sketch at most n times.Thus if we set the error probability of the AMS sketch to be 1 16n (with an extra log n factor in space), then with probability at least 1− 1 16 , all invocations of AMS sketches for testing if ∆ C = 0 will give the correct answer.Conditioned on this event, X defined in Step (6) is exactly the number of connected components B of size in G such that all vertices in B are sampled out, which is true since for any component , and thus E . Note that all Z B i 's are mutually independent for all i, so it holds that where we use the fact that scc(G) ≤ n, and p = (ε 2t n/16) −ε .Then by Chebyshev's inequality, By the union bound, the algorithm will succeed with probability at least 2 3 .

Approximating the weight of minimum spanning tree
We use the previous algorithm on estimating the number of connected components to approximate the weight of a minimum spanning tree of a weighted graph.Let W ≥ 2 be an integer, G be a connected graph with integer edge weights from [W ] := {1, • • • , W }, and c(MST) be the weight of an MST of G.For any 1 ≤ ≤ W , let G ( ) denote the subgraph of G consisting of all edges of weight at most .Let cc ( ) denote the number of connected components of G ( ) .Chazelle et al. [CRT05] give the following lemma relating the weight of MST to the number of connected components of G ( ) .

Lemma 3.3 ([CRT05]
).It holds that c(MST) = n − W + W −1 =1 cc ( ) .For a connected graph with integer edge weights, the weight of any MST is at least n − 1, so it is sufficient to estimate cc ( ) within an additive error of εn/(W − 1) for each .To do this, we can simply run W − 1 parallel instances of Theorem 3.2, each of which sketches a subgraph G ( ) .Then the space of the algorithm will be Õ(W n 1− ε W −1 ).
Theorem 3.4.Let t ≥ 1 be any constant.There exists a single-pass dynamic streaming algorithm that uses space and post-processing time O(e t W n We remark that Ahn et al. [AGM12a] have given a dynamic streaming algorithm for this problem for any graph with maximum edge weight upper bounded by O(poly(n)), and their algorithm uses space O(n • poly log n).Our algorithm uses o(n) space for any connected graph with maximum edge weight bounded by o(log n) (for constant ε), which improves the algorithm of [AGM12a] in this setting.We also note that Ω(n) space is necessary for estimating the weight of MST for graphs with maximum edge weight at least c log n for constant ε and some large universal constant c (see Theorem 5.3).Finally, we remark that the algorithm can also be extended to the setting where non-integral weights are allowed (see [CRT05] for more details).

Dynamic streaming testers
In this section, we give our streaming testers for a number of graph properties, including k-edge connectivity, cycle-freeness, and planar graph bipartiteness.We present the testers for k-vertex connectivity and Eulerianity in Appendix B.

Testing k-edge connectivity
A graph is k-edge connected if the minimum cut of the graph has size at least k.We start from the simplest case, i.e., k = 1, which is equivalent to the problem of testing connectivity.

Connectivity
It is clear that if G is ε-far from being connected, one must add at least εm edges to make it connected, which implies that there are at least εm + 1 connected components in G [GR02, PR02].Therefore, we can also solve this by estimating the number connected components by setting the error parameter appropriately, however, by a more careful analysis, we can improve this by a factor of O(n O(ε) ).
Theorem 4.1.There exists a dynamic streaming tester for 1-edge connectivity that runs in Õ(n 1−ε ) post-processing time and space.
Proof.First observe that one can simply reject the input graph if m < n − 1, since in this case, the graph is disconnected.Thus, in the following we assume m ≥ n − 1 and our tester is described in Algorithm 2.
The post-processing time is nearly linear in the size of S, since the AGM algorithm needs Õ(|S|) post-processing time, and we invoke at most |S| AMS queries, each of which takes Õ(1) time.The update time is poly log n.
For the correctness of the algorithm, we condition on the event that the number of sampled vertices is at most 16np, which occurs with probability at least 1 − 1 16 , and on the event that the spanning forest F is constructed correctly, which occurs with probability 0.99.By setting the error probability of the AMS sketch to be 1/n 2 (with an extra log n factor in space), with probability 0.99, all the answers from AMS sketches are all correct, and we also condition on this.
If G is connected, then it will always be accepted, since for each C ∈ F , ∆ C = 0, and conditioned on the correctness of the AMS sketch, F2 will never be 0. On the other hand, if the graph is εfar from being connected, the number of connected components in G, denoted as cc(G), is at Using the inequality 1 − x ≤ e −x for all x, the probability that none of the components is entirely sampled out is (1 ) ≤ e − i p i .Then by the AM-GM inequality, this probability is at most where we use the fact that p = (εn/10) −ε and cc(G) ≥ εn.So the probability that at least one of the components is sampled out is at least 15/16.Conditioned on this, F 2 (∆ C ) = 0 for some component in G[S] and the algorithm will output Reject.By union bound, our algorithm will succeed with probability 1 − 1 16 − 0.01 − 0.01 − 1 16 > 3/4.
By using a slightly more involved argument and replacing AMS sketches with (k−1)-sparse recovery sketches, we can generalize the above idea to testing k-edge connectivity for k ≥ 2. We have the following theorem on testing k-edge connectivity.The proof is deferred in Appendix A.

Testing cycle-freeness
Now we consider the problem of testing cycle-freeness, which is equivalent to testing if the graph is a forest.Let cc(G) denote the number of connected components of the input graph

and thus the total number of edges in
If G is ε-far from being cycle-free, i.e., one has to delete more than εm edges to make it cycle-free, then cc(G) > n − m + εm.Therefore, to test cycle-freeness of a graph, it will be sufficient to approximate the number of connected components with additive error εm/2.One may try to directly invoke Algorithm 1 with parameter ε = εm 2n .However, m could be much smaller than n and we do not know m in advance.We overcome this obstacle by a case analysis.
Theorem 4.3.There exists a single-pass dynamic streaming algorithm that tests cycle-freeness of a graph with space and post-processing time O(n 1−ε+ε 2 • poly log n).
Proof.Note that if m > n − 1, then the graph must contain at least one cycle, and thus we can safely reject the graph.In the following, we assume that m ≤ n − 1.Our algorithm for testing cycle-freeness depends on the construction of AGM sketch, in which each vertex u maintains a linear sketch of ∆ u (denoted as A(∆ u )).Each such sketch has size poly log n and the property that A(0) = 0 (it consists of O(log n) l 0 -samplers, see [AGM12a] for details).Our main idea is to maintain a sparse recovery sketch for the AGM sketch (i.e. a composition of sparse recovery sketch and AGM sketch).Now we describe our algorithm as follows.
Note that the space used by the algorithm is max{ Õ(np), k • poly log n} = Õ(n 1−ε+ε 2 ), and the post-processing time is near linear in space.
sufficient to set the sample probability to p = O ε (n −q(ε) ), which implies that the space used is O(n 1−Ω(ε 2 ) poly log n).We omit the details here.

Lower bounds
In this section we present lower bounds, which hold in the insertion-only model.Our proofs are based on the reductions to the Boolean Hidden Hypermatching (BHH) problem (See [VY11]), which are in the same spirit as the lower bound proof for the Cycle Counting problem in [VY11].We first give the definition of the boolean hidden hypermatching problem.
Definition 5.1 (BHH t n ).In the this problem, Alice gets a boolean vector x ∈ {0, 1} n , where n = 2kt for some integer k. Bob gets a partition (or hypermatching) of the set [n], {m 1 , • • • , m n/t }, where the size of each m i is t, and a vector w ∈ {0, 1} n/t .For convenience, we will also use the corresponding n-dimensional boolean indicator vector M i to represent m i , and let M be a n/t × n matrix, the i row of which is M i .The promise of the input is either M x + w = 1 or M x + w = 0, where all the operations are modulo 2. The goal of the problem is to output 1 when M x + w = 1, and output 0 otherwise.
We have the following lower bound from [VY11].
Our lower bounds will be built upon the following basic construction.
Observe that the edges added by Alice and Bob form two paths p 2i−1 , p 2i over vertex set S i , where p 2i−1 starts from v 2m i,1 −1 and p 2i starts from v 2m i,1 −1 for each i.The entire graph G(x, M ) consists of 2n/t disjoint paths {p 1 • • • , p 2n/t }.It also has the following property.
Fact 1.Based on the value of (M x) i , we have: ) must be picked in any minimum spanning tree, since each of these edges forms a cut, and thus the weight of any MST is nW/t+4n−n/t−1 = 4nε+4n−1, where we set t = (W −1)/4ε.On the other hand, when M x + w = 1, the weight of the MST is 4n − 1, since in this case, the graph is already connected without those edges with weight W .So if the algorithm can compute an (1 + ε)-approximation of the weight of the minimum spanning tree, it solves the BHH t n problem.This completes the proof.

Testing connectivity
Theorem 5.4.In the insertion-only model, to distinguish whether a graph of 4n vertices is connected or 1 8t+1 -far from being connected, any algorithm must use Ω(n 1−1/t ) bits of space.Proof.Given x and M , Alice and Bob first construct the graph G(x, M ).Next Bob adds another set of edges based on vector w.If w i = 0, he adds (u 2m i,t −1 , v 2m i,1 −1 ) and (u 2m i,t , v 2m i,1 ); if w i = 1, he adds (u 2m i,t −1 , v 2m i,1 ) and (u 2m i,t , v 2m i,1 −1 ).So when (M x) i + w i = 0, p 2i−1 and p 2i become 2 disjoint cycles.On the other hand, when (M x) i +w i = 1, p 2i−1 and p 2i together form a larger cycle.Now Bob places (v 2m i,t , v 2m i+1,1 ) in E for i = 1, • • • , n/t − 1 which connect p 2i with p 2(i+1) for all i ∈ [n/t − 1], i.e. all the paths in G(x, M ) with even indices become a connected component.The total number of edges is 8n + n/t.When M x + w = 0, the graph has n/t + 1 components which is 1 8t+1 -far from connected; when M x + w = 1 the graph is connected.So if a streaming algorithm can distinguish whether a graph of size 4n is connected or 1/8t-far from being connected, it solves BHH t n , since Alice can first run the algorithm on her part of the graph and send the memory to Bob, and then Bob continues to run the algorithm on his part and output the answer.Therefore, the communication lower bound of BHH t n implies a space lower bound of testing connectivity.

Testing cycle-freeness
As in the proof of Theorem 5.4, given x and M , Alice and Bob first construct G(x, M ).Then, for i ∈ [n/t], Bob adds (u 2m i,t −1 , v 2m i,1 −1 ) if w i = 0; adds (u 2m i,t −1 , v 2m i,1 ) if w i = 1.The total number of edges is less than 8n.Through similar arguments, it is easy to verify that if if M x + w = 0, the graph has exactly n/t cycles and n/t paths, which is 1/8t-far from cycle-free.On the contrary, if M x + w = 1, the graph has n/t paths and no cycle.So if an algorithm can distinguish whether a graph of size 4n is cycle-free or 1/8t-far from cycle-free, it solves BHH t n .Theorem 5.5.In the insertion-only model, any algorithm that can distinguish whether a graph of 4n vertices is cycle-free or 1/8t-far from being cycle-free, must use Ω(n 1−1/t ) bits of space.

Testing bipartiteness of planar graphs
Alice and Bob first construct the graph G(x, M ).Next, for each i ∈ [n/t], Bob adds edges (v 2m i,1 −1 , ξ 1 ) and (v 2m i,1 , ξ 2 ), where ξ 1 , ξ 2 are new vertices.For i ∈ [n/t], Bob also adds (u 2m i,t −1 , ξ 1 ) and (u 2m i,t , ξ 2 ) if w i = 0; adds (u 2m i,t −1 , ξ 2 ) and (u 2m i,t , ξ 1 ) if w i = 1.For this problem we assume t is odd.So by similar arguments, we can easily verify that, if M x + w = 0, the graph contains 2n/t edge-disjoint cycles of length 2t + 1, and if M x + w = 1, the graph has no odd cycle, and thus bipartite.The graph constructed is planar and has 4n + 2 vertices and 8n + 4n/t edges, so we have the following lower bound for testing bipartiteness.
Theorem 5.6.In the insertion-only model, any algorithm that can distinguish whether a planar graph of 4n + 2 vertices is bipartite or 1 4t+2 -far from being bipartite, must use Ω(n 1−1/t ) bits space.
Now we prove inequality (2).Note that the events (E i ∧ F i ) are not necessarily independent across i since two different -extreme subsets may contain neighbors of each other or share neighbors.We have the following simple claim to deal with this issue.
Claim 1.There exists a set I ⊂ [s], with |I| = s/k, such that: 1. |E(B i , B j )| = 0 for all i, j ∈ I and i = j, and 2.
i∈I |B i | ≤ s j=1 |B j |/k.Proof.We say B i and B j are neighbors, if |E(B i , B j )| > 0. We iteratively construct the index set I ⊂ [s] as follows.We start from the empty set and add one index at each step.Let I t denote the set that at the end of step t.In the (t + 1)-th step, we pick the smallest set B j that is not a neighbor of B h for any h ∈ I t .Note that since each -extreme set has at most k − 1 neighbors, we can always find such a set if t < s/k.Let I = I s/k .Then Item 1 of the claim follows by our construction.Now let B (t) be the set that we picked in the t-th step.Since each B (t) may intersect with at most k sets, and B (t) is the smallest set that has no intersection with all sets picked in the first t − 1 steps, there must exist a partition of [s] into s/k sets {P 1 , P 2 , • • • , P s/k }, such that for any t ≤ s/k and j ∈ P t , |B j | ≥ |B (t) |.This proves Item 2 of the claim.Now we give a lower bound for Pr[ i∈I E i ].Let p i = p |B i | be the probability that all vertices in B i are sampled.Using the fact 1 − x ≤ e −x for all x and the AM-GM inequality, we have

Thus we have
Pr i∈I since we set p = (εn/4k) −ε .Now by the property of I as guaranteed in Claim 1, it follows that F j and E i are independent for all i, j ∈ I. Hence, conditioned on the event i∈I E i , the probability of i∈I ( where in the penultimate inequality, we used the basic inequality that 1 − x ≥ e −x−x 2 for x ≤ 0.5; the last inequality holds for k ≤ 0.1/p or equivalent k ≤ O(n ε/(1+ε) ).
Finally, we have Pr We remark that the problem can still be solved in space Õ(kn 1−ε ) for larger k by testing the neighborhood of all subsets of size smaller than 1/ε in S, however the post-processing time will be Õ(kn O(1/ε) ).Also, k ≤ O(n ε ) is the most interesting case for us, since we are mostly interested in o(n) space algorithms.

B Testing other graph properties B.1 k-vertex connectivity
A graph is k-vertex connected if the minimum vertex cut of the graph has size at least k, i.e. it remains connected whenever fewer than k vertices are removed.The following lemma on the structure of graphs that are ε-far from being k-vertex connected can be directly deduced from Corollary 19 in [OR11].Proof sketch.In Corollary 19 in [OR11], it is proven that for any directed graph G that is ε-from kvertex connected, then there exists at least εm 2k subsets C of size at most 2kn εm , and either Γ + (C) < k or Γ − (C) < k.
On the other hand, in Section 5.3 in [OR11], it is proven that if G is ε-far from k-vertex connected, then the corresponding directed graph G that is obtained by turning each undirected edge (u, v) into directed edges u, v and v, u is ε-far from being k-vertex connected.Therefore, there exists at least εm Proof sketch.We can also simply consider the case that m ≥ nk/2, since otherwise the graph cannot be k-vertex connected and we can directly reject.Our approach for testing k-connectivity is similar to testing k-edge connectivity.The difference here is that now we cannot use the (k − 1)sparse recovery sketch for the vector ∆ v .Instead, for each vertex v ∈ S, we will maintain an exact k -sparse recovery sketch of the vector Λ v (defined in section 2.1), S k (Λ v ), for k = 4 ε + k.Then for each detected connected component C of size smaller than 4/ε in G[S] (by AGM sketch), recover Λ C := v∈C Λ v from the sketch S k (Λ C ) = v∈C S k (Λ v ).If it succeeds, we get the set C Γ(C), and since we know C, we get Γ(C).If |Γ(C)| < k, we reject.For any k-vertex connected graph, the tester will never reject if all the sparse recover sketches return correctly, which happens with high probability.On the other hand, if G is ε-far from k-vertex connected, by similar analysis as in k-edge connectivity together with Lemma B.1, we know that with high probability, there is a subset C ⊆ S such that G[C] is a connected component in G[S], |Γ(C)| < k and |C| ≤ 4/ε, and conditioned on this the algorithm will successfully recover Γ(C), and reject with high probability.

B.2 Testing Eulerianity
Note that the algorithm for connectivity testing can be directly used to testing Eulerianity.A graph G is Eulerian if there is a path in the graph that traverses each edge exactly once, which is equivalent to that G is connected and the degrees of all vertices are even or exactly two vertices have odd degrees.Note that if graph G is ε-far from being Eulerian then either G has Ω(εn) connected components (i.e.far from being connected) or has Ω(εn) vertices of odd degree (cf., [GR02,PR02]).Then one can test Eulerianity by first invoking the previous algorithm on testing connectivity, and then sample O(1/ε) vertices and check if some sampled vertex has odd degree.The post-processing time and space complexity of the final algorithm are Õ(n 1−c•ε ) for some universal constant c.

Algorithm 1 EstimateNumSCC 1 :
Sample each vertex with probability p := (ε 2t n/16) −ε .If more than 16np vertices are sampled, then abort and output Fail.Let S denote the set of sampled vertices.2: Maintain an AGM sketch of G[S] using Theorem 2.1.3: For each v ∈ S, maintain an AMS sketch AM S(∆ v ), sketching the neighborhood of v in G. 4: Post-Processing: 5: Use the AGM sketch to recover a spanning forest F of G[S] using Theorem 2.1.6: For each component C ∈ F , estimate F 2 (∆ C ) using the AMS sketch AM S(∆ C ) = v∈C AM S(∆ v ), and set any set B, let Z B denote the indicator random variable that all the vertices in B have been sampled.Note that Pr[Z B = 1] = p |B| .Now by the above argument, X = B∈B Z B , and E[X ] = b •p .Furthermore,

Algorithm 2 TestConnectivity 1 :
Sample each vertex with probability p := (εn/10) −ε .If more than 16np vertices are sampled, abort and output Fail.Let S denote the set of sampled vertices.2: For each v ∈ S, maintain an AMS sketch AM S(∆ v ), sketching the neighborhood of v in G. 3: Maintain an AGM sketch of G[S] using Theorem 2.1.4: Post-Processing: 5: Use the above sketch to construct a spanning forest F of G[S] as guaranteed by Theorem 2.1.6: For each connected component C ∈ F , estimate F 2 (∆ C ) using the AMS sketch AM S(∆ C ) = v∈C AM S(∆ v ).If the answer F2 = 0, Reject.7: Accept.It is easy to see that Algorithm 2 only use Õ(|S|) space, which is bounded by Õ

Figure 1 :
Figure 1: Parallel (left) and crossing (right) matching according to the value of x i

Lemma B. 1 .
If the graph is ε-far from k-vertex connected, then there exists at least εm 2k subsets C of size at most 2kn εm such that G[C] is connected and Γ(C) < k.
2k subsets C in G of size at most 2kn εm , and eitherΓ + G (C) < k or Γ − G (C) < k.This directly implies that the corresponding set C in G satisfies that Γ G (C) < k.Finally, if G[C] is not connected, then we can replace C by one maximal subset C ⊂ C such that G[C ] is connected.Note that Γ G (C ) ≤ Γ G (C) < k.This completes the proof of the lemma.Theorem B.2.Let k ≤ O(n ε/(4+ε) ).There exists a single-pass dynamic streaming tester for k-vertex connectivity with post-processing time and space complexity Õ( k 1+ε/4 ε • n 1−ε/4 ).

Table 1 :
Upper and lower bounds of streaming testers.
1 ) and (u 2m i,j , v 2m i,j+1 ) for each j ∈ [t − 1]5.1 Minimum spanning treeTheorem 5.3.In the insertion-only model, if all edges of the graph have weights in [W ], any algorithm that (1 ± ε)-approximates the weight of the MST must use Ω(n 1− 4ε W −1 ) bits of space.Proof.Given x and M , Alice and Bob first construct the graph G(x, M ) as describe above.Next Bob adds (u 2m i,t −1 , v 2m i,1 −1 ) and (u 2m i,t , v 2m i,1 ) if w i = 0; adds (u 2m i,t −1 , v 2m i,1 ) and (u 2m i,t , v 2m i,1 −1 ) if w i = 1.The weight of all the edges added so far is 1.Next Bob places edges (v 2m i,t , v 2m i+1,1 ) with weight 1 for i = 1, • • • , n/t − 1 and edges (v 2m i,t , u 2m i,t ) with weight W for each i ∈ [n/t], so that the graph become connected.By similar argument as above, if M x + w = 0, all the edges (v 2m i,t , u 2m i,t