Improved for Edge Colouring in the W-Streaming Model

Moses Charikar∗ Paul Liu†

Abstract et al. [2] shows that no can do better than In the W-streaming model, an algorithm is given a 2∆ colouring when ∆ = O(log n) (2∆ is achieved O(n polylog n) space and must process a large graph of by the greedy algorithm). On the algorithmic side, up to O(n2) edges. In this short note we give two algo- several O(∆) colouring algorithms are known, with rithms for edge colouring under the W-streaming model. approximation factors depending on whether the input For edge colouring in W-streaming, a colour for every is vertex-arrival or edge-arrival. In the vertex arrival edge must be determined by the time all the edges are model, all edges out-going from a vertex are streamed streamed. Our first algorithm uses ∆ + o(∆) colours in consecutively in a batch. In the edge-arrival model, O(n log2 n) space when the edges arrive according to a there are no constraints on the order of the edges. uniformly random permutation. The second algorithm For adversarial orders in the vertex-arrival model, the uses (1 + o(1))∆2/s colours in O˜(ns) space when edges best known result is achieved by Cohen et al. [5] arrival adversarially. using (1 + o(1))∆ colours. For random orders in the edge-arrival model, an algorithm using (1 + o(1))∆ 1 Introduction colours by Bhattacharya et al. [4] was simultaneously discovered at the same time as this paper, surpassing The problem of edge colouring asks for an assignment of the previous state-of-the-art of 1.26∆ by Bahmani et colours to the edges of a graph such that no two incident al. [1]. However, the online model allows for O(poly(n)) edges have the same colour and the total number of memory, so the methods taken by previous works do not colours used is minimized. In this short note, we apply in W-streaming. In particular, even the classic study the problem of edge colouring in the W-streaming greedy algorithm requires O(n∆) space. In the offline model. model, algorithmic versions of Vizing’s theorem [8, 11] In the W-streaming model, input is given in a gives a polynomial time ∆ + 1 colouring algorithm streaming fashion, and an output stream is written as for edge colouring. Any graph of maximum degree ∆ the input is processed. An algorithm can choose to requires at least ∆ colours, so distinguishing between ∆ stream over the input many times, although for our and ∆ + 1 is known to be NP-Hard. purposes we focus on one-pass algorithms. With respect The current state-of-the-art in W-streaming is by to edge colouring in W-streaming, an algorithm is given Behnezhad et al. [3], who achieve a 2e∆-colouring O(n polylog n) space and must process a large graph of algorithm for the random arrival case and a O(∆2) n vertices, up to O(n2) edges, and maximum degree algorithm for the adversarial arrival case. In this short ∆. During the course of the stream, each edge must be note, we give two algorithms for edge colouring under coloured by the algorithm, and their colours announced the W-streaming model that improves upon Behnezhad by the time the stream completes. Several classical et al. [3]. The first is a ∆ + o(∆) algorithm for the graph problems have been studied in the W-streaming random arrival case using O(n log n) space. The second model, including connectivity, minimum spanning tree, is a O(∆2/s) algorithm for the adversarial arrival case euler tours, and in particular edge colouring [3, 6, 7, 10]. using O˜(ns) space. Since only O(n polylog(n)) space is allowed, most edges have their colours announced close to the time they 2 A simple algorithm for edge colouring under are streamed in. In contrast to the online model, edge random arrivals colours do not have to be announced the instant they are seen. Instead, we may use our O(n polylog n) space When the edges are streamed in randomly, consider the to “buffer” the announcement of the edge colours. following simple algorithm: In the online model, a lower bound of Bar-Noy

, [email protected] †Stanford University, [email protected]

Copyright c 2021 by SIAM Unauthorized reproduction of this article is prohibited Algorithm 1: A simple algorithm for random Let u be a node of maximum degree ∆. The analysis arrivals above means we colour every chunk with at most (1 + ˆ δu)du + 1 colours. Thus the total number of colours Break the edges into C sized chunks where √ used is at most N((1+δ )dˆ +1) = ∆+O(∆/ α) with C = α2n. For each chunk, use any offline u u probability at least 1 − 1/ poly(n). ∆ + 1 coloring algorithm. For each chunk use a different palette of colours. 3 A simple algorithm for edge colouring under adversarial arrivals When the edges are streamed in adversarially, consider Theorem 2.1. When α = Ω(log n√), Algorithm 1 colours any input graph with ∆+O(∆/ α) colours with the following simple algorithm: high probability. For a ∆ + o(∆) colouring, O(n log2 n) Algorithm 2: A simple algorithm for adversarial space is sufficient. arrivals

Proof. Let Gi be the subgraph induced by chunk i, and For each node u, generate s > 36 log n random let d(u) and di(u) be the degree of u in G and Gi bits. Partition the edge set E into bipartite respectively. For the ease of exposition, assume that graphs B1,B2,...,Bs, by the following proce- C divides E exactly. The total number of chunks is dure: N = E . Fix any i ∈ {1,...,N}. Since the edges are C • Given e = (u, v) let D be the indices where randomly ordered, the expected degree of u in Gi is ˆ d(u) the random bits of u and v differ. du = N in expectation. For each of the C edges in 1 our chunk, let u,j be an indicator variable for the event • Choose an index i ∈ D uniformly at random that the j-th edge is incident on node u. Thus, we have and assign (u, v) to Bi. PC 1 di(u) = j=1 u,j. Due to the random ordering, di(u) (i) follows a hypergeometric distribution and the 1u,j’s are For each node u ∈ Bi, store a counter Cu negatively dependent. initially set to 0. Upon streaming in an edge 1 (i) (i) Applying Chernoff’s bound for negatively de- (u, v) ∈ Bi, output the colour (i, Cu ,Cv ). pendent random variables (Theorem A.1), we have (i) (i) 2 h i   Increment both Cu and Cv by 1. ˆ 2 ˆ Pr di(u) ≥ (1 + δu)du ≤ exp − min{δu, δu}du/3 . 1 ∆ Where u lies in the left partition and v lies in the Choose δu = √ . Then for δu ≤ 1, we have: Ndˆu α right partition of its bipartite graph. 2 h i The version of the algorithm we use on each bipartite ˆ graph B is the same as the one used in [3]. Pr di(u) ≥ (1 + δu)du i  ∆2  ≤ exp − 2 ˆ 3N duα Theorem 3.1. Algorithm 2 colours any input graph  ∆  with (1 + o(1))∆2/s colours in O˜(ns) space. ≤ exp − (dˆ ≤ ∆/N) 3Nα u Proof. First, we show that the graphs B produced in   i αn∆ E Algorithm 2 are indeed bipartite. By construction, = exp − (N = 2 ) 3E α n every edge (u, v) in graph Bi connects a node whose ≤ exp (−α/3) (E ≤ n∆) i-th bit is 0 with a node whose i-th bit is 1. Thus the = 1/ poly(n)(α = Ω(log n)) left partition of Bi is precisely the nodes with their i-th bit equal to 0 and the right partition is precisely the where we may adjust the degree of the poly(n) as high nodes with their i-th bit equal to 1. as we like (by adjusting α). The case for δu > 1 achieves Next, we show that the maximum degree of each similar 1/ poly(n) bounds. Bi is concentrated about ∆/s. Let du,v be the number ˆ differing bits between u and v. For any two vertices u Thus for every u in Gi, we have di(u) ≤ (1 + δ)du and v, the expected value of d random bits is s/2. with probability 1 − 1/ poly(n). Let 1i be the indicator u,v By a Chernoff bound, variable for this event happening for Gi. By a union bound, we have 3 Pr [du,v ≤ s/4] ≤ exp(−s/12) ≤ 1/n . N  N 1  X 1 Thus by a union bound, every pair of nodes will have Pr ∩i=1 i ≥ 1 − (1 − Pr [ i]) ≥ 1 − 1/ poly(n). i=1 at least s/4 differing bits. By symmetry, any index

Copyright c 2021 by SIAM Unauthorized reproduction of this article is prohibited is equally likely to differ between any pair of nodes. algorithm in the random order arrival model. In Moses For each edge, we choose a random index out of all Charikar, editor, Proceedings of the Twenty-First An- the differing indices to assign the edge to. Thus the nual ACM-SIAM Symposium on Discrete Algorithms, SODA 2010, pages 31–39. SIAM, 2010. maximum degree of each Bi is ∆/s in expectation. Furthermore, the expectation is tightly concentrated [2] Amotz Bar-Noy, , and Joseph Naor. around ∆/s when ∆/s = Ω(log n) (when ∆/s = The greedy algorithm is optimal for on-line edge color- ing. Inf. Process. Lett., 44(5):251–253, 1992. o(log n), O(ns polylog n) is enough space to store the [3] Soheil Behnezhad, Mahsa Derakhshan, Mohammad- entire graph). Taghi Hajiaghayi, Marina Knittel, and Hamed Saleh. Finally, we prove the correctness and space guaran- Streaming and massively parallel algorithms for edge tees of the algorithm. In the colours we assign, the first coloring. In Michael A. Bender, Ola Svensson, and index guarantees that each bipartite graph uses a dis- Grzegorz Herman, editors, 27th Annual European Sym- tinct palette of colours. Now fix a particular bipartite posium on Algorithms, ESA 2019, volume 144 of graph Bi. We first argue correctness. Let u be a node of LIPIcs, pages 15:1–15:14. Schloss Dagstuhl - Leibniz- the left partition. Since a counter is incremented when- Zentrum f¨urInformatik, 2019. ever it’s used, it’s clear that no edge incident on node u [4] Sayan Bhattacharya, Fabrizio Grandoni, and David will ever reuse a value for the second coordinate of the Wajc. Online algorithms for edge coloring via the colour. The right partition follows a similar argument nibble method. In the 32nd Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2021, 2021. for the third coordinate of the colour. Note the bipar- [5] Ilan Reuven Cohen, Binghui Peng, and David Wajc. tite structure of the graph is crucial here, as it allows Tight bounds for online edge coloring. In David us to distinguish between the left node and right node Zuckerman, editor, 60th IEEE Annual Symposium on of every edge. Foundations of Computer Science, FOCS, pages 1–25. Since we increment by 1 on the addition of every IEEE Computer Society, 2019. edge incident to a node, the counter values can only [6] Camil Demetrescu, Bruno Escoffier, Gabriel Moruz, be incremented as high as the maximum degree of and Andrea Ribichini. Adapting parallel algorithms the graph. As the maximum degree of each Bi is to the W-Stream model, with applications to graph ∆/s in expectation, the counter values are at most problems. Theor. Comput. Sci., 411(44-46):3994–4004, ∆/s in expecation (and tightly concentrated when ∆ 2010. is large). Summing over all s bipartite graphs, the [7] Camil Demetrescu, Irene Finocchi, and Andrea Ribi- chini. Trading off space for passes in graph stream- total number of possible colours is tightly concentrated 2 2 ing problems. ACM Trans. Algorithms, 6(1):6:1–6:17, around s(∆/s) = ∆ /s. 2009. Finally, the algorithm uses at most O(ns log(∆/s)) [8] Reinhard Diestel. Graduate texts in mathematics. space, as each vertex uses s counters, and each counter Graph theory, 173, 2000. is at most O(∆/s). [9] Benjamin Doerr. Probabilistic tools for the anal- 2 ysis of randomized optimization heuristics. CoRR, Worst case examples. The bound of O(∆ /s) abs/1801.06733, 2018. can be achieved in the worst case for Algorithm 2 given [10] Christian Glazik, Jan Schiemann, and Anand Srivas- access to the randomness of the algorithm. Let an t- tav. Finding euler tours in one pass in the w-streaming star be the graph of t edges incident to node u, and model with O(nlog(n)) RAM. CoRR, abs/1710.04091, let s be the space parameter s in Algorithm 2. By 2017. streaming in poly(∆s) copies of a ts-star, we guarantee [11] Jayadev Misra and David Gries. A constructive proof the existence of t-stars in each of the bipartite subgraphs of vizing’s theorem. Inf. Process. Lett., 41(3):131–133, 1992. B1,B2,...,Bs for any t. Now any colour (i, j, k) may be created by connecting the centres of a j-star and a k-star in graph Bi. Note that we need to create poly(s) A Appendix copies of the j-star and k-star to connect, so that the A.1 Auxiliary Results edge connecting the centres of the stars falls into Bi. Creating all possible combinations of (i, j, k), we obtain Theorem A.1. ([9]) Let X1,...,Xn be negatively de- a graph using O(∆2/s) colours in poly(∆s) nodes with pendent random variables such that Xi ∈ [0, 1] with Pn maximum degree ∆. probability 1. Define X = i=1 Xi and let µ = EX. Then, for any  > 0, we have References  min{, 2}µ Pr[X ≥ (1 + )µ] ≤ exp − . 3 [1] Bahman Bahmani, Aranyak Mehta, and Rajeev Mot- wani. A 1.43-competitive online graph edge coloring

Copyright c 2021 by SIAM Unauthorized reproduction of this article is prohibited