On Dynamic Breadth-First Search in External-Memory
We provide the first non-trivial result on dynamic breadth-first search (BFS) in external-memory: For general sparse undirected graphs of initially $n$ nodes and O(n) edges and monotone update sequences of either $\Theta(n)$ edge insertions or $\Thet…
Authors: Ulrich Meyer
Symposium on Theoretical Aspects of Computer Science 2008 (Bordeaux), pp. 551-560 www .stacs-conf .org ON D YNAMIC BREADTH-FIRST SEARCH IN EXTERNAL-MEMOR Y ULRICH MEYER 1 1 Institute for Computer Science, J. W. Goeth e Universit y, 60325 F rankfurt/Main, German y E-mail addr ess : umeyer@ae. cs.uni- frankfurt.de Abstra ct. W e provide the first non- t rivial result on dynamic breadth -first search (BFS) in external-memory: F or general sparse undirected graphs of initially n no des and O ( n ) edges and monotone up date sequences of either Θ( n ) edge insertions or Θ( n ) edge deletions, w e prov e a n amortized high-probabilit y boun d of O ( n/B 2 / 3 + sort( n ) · l og B ) I /Os p er up date. In contrast, the currently b est approach for static BFS on sparse undirected graphs requires Ω( n/B 1 / 2 + sort( n )) I /Os. 1. In tro duction Breadth fi rst searc h (BFS) is a fundamental graph tra v ersal strategy . It can also b e view ed as computing single source shortest paths on unw eigh ted graphs. I t decomp oses the input graph G = ( V , E ) of n no des and m edges into at most n lev els where lev el i comprises all no des that can b e reac hed from a designated sour ce s via a path of i edges, but cannot b e reac hed using less than i edges. The ob jectiv e of a dynamic graph algorithm is to efficien tly pro cess an online sequence of up date and qu ery op erations; see [8, 14] for o v erviews of classic and recen t r esults. In our case we consid er BFS un der a sequence of either Θ( n ) edge insertions, but not deletions ( incr emental v ersion) or Θ( n ) edge deletio n s, but not insertions ( de cr emental v ersion). After eac h edge insertion/deletion the up dated BFS lev el d ecomp osition has to b e outp u t. 1.1. Computation mo dels. W e consider the commonly accepted external-memory (EM) mod el of Agga rwal and Vitter [1]. It assumes a tw o lev el memory hierarc h y with faster in ternal memory ha ving a capacit y to s tore M v ertices/edge s. In an I/O op eration, one blo c k of data, whic h can store B v ertices/e d ges, is transferr ed b et ween disk and in ternal memory . The measure of p erforman ce of an algorithm is the num b er of I/Os it p erforms. The num b er of I/Os needed to read N con tiguous items fr om d isk is s can( N ) = Θ( N /B ). The num b er of I/Os required 1998 ACM Subje ct C lassific ation: F.2.2. Key wor ds and phr ases: External Memory , Dynamic Graph Algorithms, BFS, R andomization. P artially supp orted by the DFG gran t ME 3250/1-1, and by the cen ter of massive data algorithmics (MADALGO) funded by the Danish National Research F oundation. c U. Meyer CC Creative Comm on s Attribution-NoDer ivs L icense 552 U. MEYER to sort N items is sort( N ) = Θ(( N /B ) log M /B ( N/B )). F or all realistic v alues of N , B , and M , scan( N ) < sort( N ) ≪ N . There has b een a significant n umb er of pub lications on external-memory graph algo- rithms; see [12, 16] for recent o v erviews. Ho wev er, we are n ot a w are of any dynamic graph algorithm in the fully external-memory case (where | V | > M ). 1.2. Results. W e provide the fi rst non-trivial result on dyn amic BFS in external-memory . F or general sparse und irected graphs of initially n n o des and O ( n ) edges an d either Θ( n ) edge ins er tions or Θ( n ) ed ge deletions, we pro ve an amortized high-probabilit y b ou n d of O ( n/B 2 / 3 + sort( n ) · log B ) I /Os p er up date. In con trast, the curr en tly b est b ound for static BFS on sparse undirected graphs is O ( n/B 1 / 2 + sort( n )) I/Os [11]. Also note that for general sparse graphs and w orst-case monotone sequences of Θ( n ) up d ates in internal-memory there is asymptotica lly no b etter solution than p erforming Θ( n ) runs of the linear-time static BFS algo rithm , eve n if after eac h up date we are just required to rep ort the c hanges in the BFS tree (see Fig. 1 for an example). In case Ω( n/B 1 / 2 + so rt( n )) I/Os should pro ve to b e a lo wer b ound for static BFS in external-memory , then our result yields an interesting differentia tor b etw een static vs. dynamic BFS in internal and external memory . X s Y Z 00 00 00 11 11 11 00 00 00 11 11 11 00 00 00 11 11 11 00 00 00 11 11 11 00 00 00 11 11 11 00 00 00 11 11 11 00 00 00 11 11 11 00 00 00 11 11 11 00 00 00 11 11 11 00 00 00 11 11 11 00 00 00 11 11 11 00 00 00 11 11 11 00 00 00 11 11 11 00 00 00 11 11 11 00 00 00 11 11 11 00 00 00 11 11 11 00 00 00 11 11 11 00 00 00 11 11 11 00 00 00 11 11 11 00 00 00 11 11 11 00 00 00 11 11 11 00 00 00 11 11 11 00 00 00 11 11 11 00 00 00 11 11 11 00 00 00 11 11 11 00 00 00 11 11 11 00 00 00 11 11 11 00 00 00 11 11 11 00 00 00 11 11 11 00 00 00 11 11 11 00 00 00 11 11 11 Figure 1: Example for a graph class where eac h u p d ate requires Ω( n ) c hanges in th e BFS tree: in s erting n ew (dashed) edges alternatingly shortcut the distances from s to X an d s to Y . As a result, in the up dated BFS tree the parents of all v ertices in Z k eep on c hanging b et wee n X and Y . 1.3. Organization of the pap er. In S ection 2 we will review kno wn BFS algorithms for static und irected graphs. Then w e consider traditional and new external-memory m etho ds for graph clustering (Section 3). Subsequ ently , in Section 4 we p ro vide the new algorithm and analyze it in Section 5. Final remarks concernin g extensions and op en problems are giv en in Sections 6 and 7, resp ectiv ely . 2. Review of Static BFS Algorithms In ternal-Memory . BFS is well-understo o d in the RAM m o del. T h ere exists a simple linear time algorithm [6] (hereafter referred as IM BFS) for the BFS tra v ersal in a graph . IM BFS k eeps a set of app ropriate candidate n o des f or the next vertex to b e visited in a FIF O queue Q . F urtherm ore, in ord er to find out the un visited neigh b ors of a no de from its adjacency list, it marks th e no d es as either v isited or unvisit ed. ON DYNAMIC BREADTH-FIRST SEARCH IN EXTERNAL-MEMOR Y 553 Unfortunately , as the storage requiremen ts of the graph starts a p proac hing the size of the internal memory , the runn ing time of this algorithm deviates significant ly from the predicted O ( n + m ) asymptotic p er f ormance of the RAM mo del: c hec king whether edges lead to already visited no d es altogether n eeds Θ ( m ) I/Os in the wo rs t case; u nstructured indexed access to adjacency lists ma y add another Θ( n + m/B ) I/Os. EM-BFS f or dense undirected graphs. The algorithm by Munagala and R an ad e [13] (referred as MR BFS) ignores the second problem but addresses the first by exploiting the fact that the neighbors of a n o de in BFS leve l t − 1 are all in BFS lev els t − 2, t − 1 or t . Let L ( t ) denote the set of n o des in BFS lev el t , and let A ( t ) b e the multi-se t of neigh b ors of no des in L ( t − 1). Giv en L ( t − 1) an d L ( t − 2), MR BFS bu ilds L ( t ) as follo ws: Firstly , A ( t ) is created by | L ( t − 1) | random accesses to get h old of the adjacency lists of all no des in L ( t − 1). Th ereafter, d u plicates are remov ed from A ( t ) to get a sorted set A ′ ( t ). This is done b y s orting A ( t ) according to n o de indices, follo w ed b y a s can and compaction phase. The set L ( t ) := A ′ ( t ) \ { L ( t − 1) ∪ L ( t − 2) } is computed by scanning “in parallel” the sorted sets of A ′ ( t ) , L ( t − 1), and L ( t − 2) to fi lter out the n o des already pr esen t in L ( t − 1) or L ( t − 2). The resulting worst-ca se I/O-b ound is O ( P t L ( t ) + P t sort( A ( t ))) = O ( n + sort( n + m )). The algorithm outpu ts a BFS-lev el decomp osition of the v ertices, whic h can b e easily trans- formed int o a BFS tr ee usin g O (sort( n + m )) I/Os [4]. EM-BFS for sparse undirected graphs. Mehlhorn and Meyer s uggested another ap- proac h [11] (MM BFS) which inv olv es a prepr o cessing p hase to restructure th e adjacency lists of the graph representati on. It groups the v ertices of the input graph in to d isjoin t clusters of small diamet er in G and stores the adjace n cy lists o f the no d es in a cluster con tiguously on the disk . Thereafter, an appropr iately mo dified v ersion of MR BFS is run . MM BFS exploits the fact that whenev er the first no de of a cluster is visited then the remaining no des of this cluster will b e reac hed so on after. By sp ending only one random access (and p ossibly , some sequential accesses dep end ing on cluster size) to load the whole cluster and th en k eeping the cluster data in some efficiently accessible data s tr ucture (p o ol) unt il it is all p ro cessed, on sp arse graphs the total amoun t of I/Os can b e reduced b y a factor of up to √ B : the neigh b oring no des of a BFS lev el can b e computed simply by scanning the p o ol and not th e whole grap h . Though some edges may b e scanned more often in the p o ol, unstructured I/Os to fetc h adjacency lists is considerably reduced, th er eby reducing the total num b er of I/Os. 3. Prepro cessing 3.1. T raditional prepro cessing within MM BFS. Mehlhorn and Mey er [11] prop osed the algorithms MM BFS R and MM BFS D, out of wh ic h the first is r andomized and th e second is deterministic. In MM BFS R, the par- titioning is generated “in parallel round s”: after choosing master n o des in dep end en tly and uniformly at random, in eac h roun d, eac h m aster no de tries to capture all u n visited neigh- b ors of its cur ren t sub -graph into its partition, with ties b eing resolved arbitrarily . 554 U. MEYER A similar kind of randomized pr ep ro cessing is also applied in parallel [15] and stream- ing [7] settings. Th ere, ho wev er, a dense compressed graph among the master no des is pro du ced, causing r ather h igh parallel w ork or large total streaming vol u me, resp ectiv ely . The MM BFS D v arian t firs t bu ilds a spanning tree T s for the connected comp onent of G that conta ins the source no de. Arge et al. [2] sho w an upp er b ound of O ((1 + log log ( B · n/m )) · s ort( n + m )) I/Os f or computin g such a sp an n ing tree. Eac h undi- rected edge of T s is then replaced by t w o opp ositely dir ected edges. Not e that a bi-directed tree alw a ys has at least one Euler tour. In ord er to construct the Euler tour around this bi-directed tree, eac h no de c ho oses a c yclic order [3] of its neigh b ors. The s uccessor of an incoming edge is d efined to b e th e outgoing edge to the next n o de in the cyclic order. The tour is then b rok en at the source no de and the elemen ts of the r esulting list are then stored in consecutiv e ord er using an external memory li st-rankin g algo rithm ; Ch iang et al. [5 ] s h o we d ho w to do this in sorting complexit y . T hereafter, we c hop th e Euler tour into chunks of max { 1 , q n · B n + m } no d es and remo v e duplicates suc h that eac h no de only remains in the first c h un k it originally occur s; again this requires a couple of sorting s teps. The adjacency lists are then re-ordered based on the p osition of th eir corresp onding n o des in the c hopp ed dup licate-free Euler tour: all adjacency lists for no des in the same c h un ks form a clus ter and the distance in G b et wee n an y t wo v ertices wh ose adjacency-lists b elong to the same cluster is b ounded by max { 1 , q n · B n + m } . 3.2. Mo dified prepro cessing for dynamic BFS. The prepro cessing metho d s for the s tatic BFS in [11] ma y p r o duce v ery un balanced clusters: for examp le, with MM BFS D using ch unk size 1 < µ < O ( √ B ) there ma y b e Ω( n/µ ) clusters b eing in c h arge of only O (1) adjacency-lists eac h. F o r th e dynamic version, ho wev er, w e would lik e to argue that eac h random access to a cluster not visited so far pro vides us with Ω( µ ) new adjacency-lists. Unfortunately , find ing suc h a clustering I/O- efficien tly seems to b e quite hard. Therefore, w e shall already b e satisfied with an Euler tour based randomized construction ensuring that th e exp e cte d n umb er of adjacency-lists k ept in all b ut one 1 clusters is Ω( µ ). The prepr o cessing from MM BFS D is mo dified as follo ws: eac h v ertex v in the s panning tree T s is assigned an indep endent b in ary random num b er r ( v ) with P [ r ( v ) = 0] = P [ r ( v ) = 1] = 1 / 2. When remo ving du plicates from the Euler tour , in s tead of storing v ’s adjacency- list in the cluster related to the c hunk with the first o ccurrence of a vertex v , now we only stic k to its fir st o ccurren ce iff r ( v ) = 0 and otherwise ( r ( v ) = 1) store v ’s adjacency-list in the cluster that corresp onds to the last c hunk of the Euler tour v app ears in. F or leaf n o des v , ther e is only one o ccur rence on the tour, hen ce th e v alue of r ( v ) is irrelev an t. Ob viously , eac h adjacency-lists is s tored only once. F urthermore, the mo d ified pro cedu r e main tains all go o d prop erties of the stand ard prepr o cessing w ithin MM BFS D lik e guaran teed b ounded distances of O ( µ ) in G b et wee n the ve r tices b elonging to th e same cluster and O ( n/µ ) clusters o verall . Lemma 3.1. F or chunk size µ > 1 and e ach but the last ch unk , the exp e cte d numb er of adjac ency- lists kept is at le ast µ/ 8 . 1 The last c hunk of the Euler tour only visits ((2 · n ′ − 1) mod µ ) + 1 vertices where n ′ denotes the num b er of vertice s in the connected comp onent of the starting no de s . ON DYNAMIC BREADTH-FIRST SEARCH IN EXTERNAL-MEMOR Y 555 Pr o of. Let R = ( v 1 , . . . , v µ ) b e the sequence of v ertices visit ed b y an arbitrary c hunk R of the Euler tour T , excluding the last c h un k. Let a b e the num b er of en tries in R that represent fir st or last visits of inn er-tree v ertices from the sp anning tree T s on T . These a en tries accoun t f or an exp ected num b er of a/ 2 adjacency-lists actually s tored and k ept in R . Note that if for some vertex v ∈ T b oth its firs t and last visit happ en within R , then v ’s adjacency-list is k ept with pr obabilit y one. Similarly , if there are any visits of leaf no des from T s within R , then th eir adjacency-lists are k ept for sure; let b denote the num b er of these leaf no de en tries in R . What remains are µ − a − b interme diate (neither first nor last) visits of v ertices within R ; they do not contribute any additional adjacency-lists. W e can b oun d µ − a − b usin g the observ atio n that any in termediate v isit of a tree no de v on T is p receded by a last visit of a c h ild v ′ of v and p ro ceeded by a first visit of another child v ′′ of v . Thus, µ − a − b ≤ ⌈ µ/ 2 ⌉ , that is a + b ≥ ⌊ µ/ 2 ⌋ , wh ic h imp lies that the exp ected num b er of distinct adjacency-lists b eing k ept for R is at least ⌊ µ/ 2 ⌋ / 2 ≥ µ/ 8. 4. The Dynamic Incremen tal Algorithm In this section we concentrat e on the incremen tal ve r sion for sparse graphs with Θ( n ) up d ates wh ere eac h up date in serts an edge. Th u s, BFS level s can on ly decrease o ve r time. Before we start, let us fix s ome notation: for i ≥ 1, G i = ( V , E i ) is to denote the graph after the i -th u p d ate, G 0 is the initial graph . L et d i ( v ), i ≥ 0, stand for the BFS lev el of no de v if it can b e reac hed from the source n o de s in G i and n otherwise. F urthermore, for i ≥ 1, let ∆ d i ( v ) = | d i − 1 ( v ) − d i ( v ) | . The m ain ideas of our approac h are as follo ws: Chec king Connectivity; T yp e A up dates. In ord er to compute the BFS level s for G i , i ≥ 1, w e fi r st r un an EM connected comp onen ts algorithm (for example the one in [13] taking O (sort( n ) · log B ) I/Os) in order to c hec k, whether the insertion of the i -th edge ( u, v ) enlarges th e connected comp onent C s of the source vertex s . If y es (let u s call this a T yp e A up da te ), then w.l.o.g. let u ∈ C s and let C v b e th e connected comp onent that comprises v . The new edge ( u, v ) is then the only conn ection b et w een th e existing BFS-tree for s and C v . Therefore, w e can simp ly run MR BFS on the su bgraph G ′ defined by the vertic es in C v with source v and add d i − 1 ( u ) + 1 to all distances obtained. This tak es O ( n v + sort( n )) I/Os where n v denotes the num b er of v ertices in C v . If the i -th up date d o es not merge C s with some other connected comp onen t but adds an edge within C s ( T yp e B up da te ) th en w e need to d o somethin g more fancy: Dealing w ith small c hanges; Type B up dat es. No w for computing the BFS lev els for G i , i ≥ 1, we pre-feed th e adjacency-lists into a sorted p o ol H according to the BFS lev els of their r esp ectiv e v ertices in G i − 1 using a certain adv ance α > 1, i.e., the adjacency list for v is added to H when creating BFS lev el m ax { 0 , d i − 1 ( v ) − α } of G i . This can b e d one I/O-efficien tly as follo ws. First w e extract the adjacency-lists for vertice s h a ving BFS lev els up to α in G i − 1 and put them to H where they are kept sorted by no de indices. F rom the remaining adjacency-lists w e bu ild a sequence S b y sorting them according to BFS lev els in G i − 1 (primary criterion) and n o de in dices (secondary criterion). F or the construction of eac h new BFS lev el of G i w e merge a sub s equence of S acco u n ting for one BFS level in G i − 1 with H us ing s imple scanning. Therefore, if ∆ d i ( v ) ≤ α for all v ∈ V then all adjacency-lists will b e added to H in time and can b e consumed from there without ran d om I/O. Eac h adj acency-list is scann ed 556 U. MEYER at most once in S and at most α times in H . Th us, if α = o ( √ B ) this approac h causes less I/O than MM BFS. Dealing w ith larger c hanges. Unfortun ately , in general, there m ay b e vertices v with ∆ d i ( v ) > α . Th eir adjacency-lists are not prefetc hed in to H early enough and therefore ha ve to b e imported in to H using rand om I/Os to w h ole clusters just lik e it is done in MM BFS. Ho w eve r, we apply the mo dified clustering pr o cedure describ ed in Section 3.2 on G i − 1 , the graph without the i -th new edge (whose conn ectivit y is the same as that of G i ) with c hunk size α/ 4. Note that this may result in Θ( n/α ) cluster accesses, whic h wo u ld b e prohib itive for small α . Therefore w e r estrict th e num b er of random cluster accesses to α · n/B . If the dynamic algorithm d o es not succeed w ith in these b ounds then it increases α by a factor of t wo , computes a new clusterin g for G i − 1 with larger c h un k size and starts a new attemp t b y rep eating the whole approac h with th e increased p arameters. Note that w e d o not n eed to recompute the spann ing tr ee for the for the second, th ir d, . . . attempt. A t most O (log B ) attempts p er up date. The j -th attempt, j ≥ 1, of the dynamic approac h to p ro duce the new BFS-lev el d ecomp osition will apply an adv ance of α j := 32 · 2 j and recompute the mo dified clustering for G i − 1 using ch unk size µ j := 8 · 2 j . Note th at there can b e at most O (log √ B ) = O (log B ) failing attempts for eac h edge u p d ate since by then our app roac h allo ws suffi cien tly man y r andom accesses to clusters so that all of them can b e loaded explicitly resulting in an I/O-b ound comparable to that of static MM BFS. In Section 5, ho wev er, w e w ill argu e that for most edge up dates within a longer sequence, the adv ance v alue and th e c h unk size v alue for the succeeding attempt are b ounded by O ( B 1 / 3 ) imp lying significant ly impro ved I /O p erformance. Restricting waiting time in H . There is one more imp ortan t d etail to tak e care of: when adjacency-lists are brought in to H via exp licit cluster accesses (b ecause of in sufficien t adv ance α j in th e prefetc hing), these adjace ncy-lists will re-en ter H once more la ter on during th e (for these adjacency-lists by then u seless) pr efetc hing. T h us , in order to mak e sure that unnecessary adjacency-l ists do not stay in H forev er, eac h en try in H carries a time-stamp ensuring that sup erfl uous adjacency-lists are evicted from H after at most α j = O (2 j ) BFS lev els. Lemma 4.1. F or sp ars e gr aphs with O ( n ) up dates, e ach T yp e B up date suc c e e ding during the j -th attempt r e quir es O (2 j · n/B + sort( n ) · log B ) I/Os. Pr o of. Deciding whether a Typ e B up date tak es place essentially requires a connected com- p onents computation, wh ic h account s for O (sort( n ) · log B ) I/Os. Within th is I/O b ound w e can also compu te a spanning tree T s of the comp onent holding th e starting verte x s but exclud in g th e n ew ed ge. Subsequently , there are j = O (log B ) attempts, eac h of w hic h uses O (sort( n )) I/Os to d eriv e a n ew mo dified clus tering based on an Euler tour with in- creasing c hunk s izes aroun d T s . F urtherm ore, b efore eac h attempt we need to initializ e H and S , wh ic h tak es O (sort( n )) I/Os p er attempt. The wo r s t-case num b er of I/Os to (re-) scan adjacency-lists in H or to explicitly fetch clusters of adjacency-lists d ou b les after eac h attempt. T herefore it asymptotically suffices to consider the (successful) last attempt j , whic h c auses O (2 j · n/B ) I/Os. F ur thermore, eac h attempt requires another O (sort( n )) I/Os to p re-sort explicitly loaded clusters b efore they can b e m erged with H using a sin- gle scan jus t lik e in MM BFS. Adding all con tributions yields the claimed I/O b ound of O (2 j · n/B + sort( n ) · log B ) for spars e graph s. ON DYNAMIC BREADTH-FIRST SEARCH IN EXTERNAL-MEMOR Y 557 5. Analysis W e sp lit our analysis of the incremen tal BFS algorithm into t wo parts. The first (and easy one) tak es care of Typ e A up dates: Lemma 5.1. F or sp arse undir e cte d gr aphs with Θ( n ) up dates, ther e ar e at most n − 1 T yp e A up da tes c ausing O ( n · sort( n ) · log B ) I/Os in total. Pr o of. Eac h T yp e A u p d ate starts with an EM connected comp onent s computation causing O (sort( n ) · log B ) I /Os p er up date. Since eac h no de can b e added to the connected comp o- nen t C s holding the s tarting verte x s only once, the total num b er of I/Os sp end in calls to the MR-BFS algorithm on comp onen ts to b e merged with C s is O ( n + sort( n )). Pro ducing the output tak es another O (sort( n )) p er up date. No w we tur n to Typ e B up dates: Lemma 5.2. F or sp arse undir e cte d gr ap hs with Θ ( n ) up dates, al l T yp e B up dates c ause O ( n · ( n 2 / 3 + sort ( n ) · log B )) I/Os in total with high pr ob ability. Pr o of. Recall that d i ( v ), i ≥ 0, stand s for the BFS lev el of no de v if it can b e reac hed f r om the sour ce no d e s in G i and n otherwise. I f up on the i -th up date th e dynamic algorithm issues an explicit fetc h for the adjacency-lists of some v ertex v k ept in some cluster C then this is b ecause ∆ d i ( v ) = d i − 1 ( v ) − d i ( v ) > α for the current adv ance α . Note that for all other ve rtices v ′ ∈ C , there is a path of length at most µ in G i − 1 , implyin g that | d i − 1 ( v ′ ) − d i − 1 ( v ) | ≤ µ as wel l as | d i ( v ) − d i ( v ′ ) | ≤ µ . Ha ving current ch unk size µ = α/ 4, this implies ∆ d i ( v ′ ) = d i − 1 ( v ′ ) − d i ( v ′ ) = d i − 1 ( v ′ ) − d i − 1 ( v ) + d i − 1 ( v ) − d i ( v ) + d i ( v ) − d i ( v ′ ) > α − 2 µ ≥ α/ 2 . If the i -th up date n eeds j attempts to succeed then, du ring the (failing) attempt j − 1, it has tried to exp licitly access α j − 1 · n/B + 1 distinct clusters. Out of these at least α j − 1 · n/B = 2 j +4 · n/B clusters carry an exp ected amoun t of at least µ j − 1 / 8 = 2 j − 1 adjacency-lists eac h . This accounts for an exp ected num b er of at least 2 2 · j +3 · n/B distinct v ertices, eac h of them featuring ∆ d i ( · ) ≥ α j − 1 / 2 = 2 j +3 . With probability at least 1 / 2 we actually get at least half of the exp ected amount of distinct vertice s/adjacency-lists, i.e., 2 2 · j +2 · n/B . T herefore, using the d efi nitions D i = P v ∈ V \{ s } d i ( v ) and ∆ D i = | D i − 1 − D i | , if the i -th u p date s ucceeds within the j -th attempt we hav e ∆ D i ≥ 2 3 · j +5 · n/B =: Y j with probabilit y at least 1 / 2. Let us call this even t a lar ge j -yie ld . Since eac h attempt uses a n ew clustering with indep en den t choic es for r ( · ), if we consider t wo up dates i ′ and i ′′ that succeed after th e same num b er of attempts j , then b oth i ′ and i ′′ ha ve a large yield with prob ab ility at least 1 / 2, indep endent of eac h other. Therefore, w e can use Chernoff b ounds [10 ] in ord er to sh o w that out of k ≥ 16 · c · ln n up d ates that all succeed within their j -th attempt, at least k / 4 of th em ha v e a large j -yield w ith probabilit y at least 1 − n − c for an arbitrary p ositiv e constan t c . Su b sequent ly w e will p ro ve an upp er b ound on the total n umb er of large j -yields that can o ccur durin g the whole up d ate sequence. 558 U. MEYER The q u an tit y ∆ D i pro vides a global measure as for ho w muc h the BFS lev els c hange after inclusion of the i -th edge from the up date sequence. If there are m ′ = Θ( n ) edge inserts in total, then n 2 > D 0 ≥ D 1 ≥ . . . ≥ D m ′ − 1 ≥ D m ′ > 0 . A large j -yield means ∆ D i ≥ Y j . T herefore, in the worst case there are at most n 2 / Y j = n 2 / (2 3 · j +5 · n/B ) = n · B / 2 3 · j +5 large j -yield up dates and – according to our discus s ion ab o ve – it needs at most k j := 4 · n · B / 2 3 · j +5 up d ates that succeed within the j -th attempt to ha ve at least k j / 4 large j -yield up dates with high pr obabilit y 2 . F or the last s tep of our analysis w e will distinguish t wo kinds of Typ e B u p d ates: those that finish us ing an adv ance v alue α j ∗ < B 1 / 3 (T yp e B1), and th e others (Typ e B2). Indep endent of the su bt yp e, an u p d ate costs O ( α j ∗ · n /B + sort( n ) · log B ) = O (2 j ∗ · n /B + sort( n ) · log B ) I/Os by Lemma 4.1. Ob viously , for an u p d ate s equence of m ′ = Θ( n ) edge insertions there can b e at most Θ( n ) up dates of Typ e B1, eac h of them accoun ting for at most O ( n/B 2 / 3 + sort( n ) · log B ) I/Os. As for Type B2 u p d ates we h av e already s ho wn that with high probab ility there are at most O ( n · B / 2 3 · j ∗ ) up dates that succeed with adv ance v alue Θ(2 j ∗ ). T herefore, using Bo ole’s inequalit y , the total amount of I/Os for all T yp e B2 up d ates is b ounded by O X g ≥ 0 n · B ( B 1 / 3 · 2 g ) 3 · B 1 / 3 · 2 g · n B + n · sort( n ) · log B = O ( n · ( n/B 2 / 3 + sort ( n ) · log B )) with high p robabilit y . Com binin g the t wo lemmas of this s ection implies Theorem 5.3. F or ge ner al sp arse undir e cte d gr aphs of ini tial ly n no des and O ( n ) e dges and Θ( n ) e dge i nsertions, dynamic BFS c an b e solve d using amortize d O ( n/B 2 / 3 + sort( n ) · log B ) I/Os p er up date with high pr ob ability. 6. Decremen tal V ersion and Extensions. Ha ving gone through the ideas of the in cr emental v ersion, it is no w close to trivial to come u p with a symmetric external-memory dyn amic BFS algorithm for a sequence of edge deletions: instead of pre-feeding adjacency-lists into usin g an advanc e of α j lev els, w e no w apply a lag of α j lev els. Therefore, the adjacency-list for a vertex v is found in H as long as the deletion of the i -th edge do es n ot increase d i ( v ) b y m ore than α . Otherwise, an explicit random access to the cluster con taining v ’s adjacency-list is issued later on. All p reviously used amortization argumen ts and b ound s carry through, th e only d ifference b eing that d i ( · ) v alues may mon otonically in crease instead of decrease. Better amortized b ound s can b e obtained if ω ( n ) up dates tak e place and/or G 0 has ω ( n ) edges. T hen we ha v e the p oten tial to amortize more r andom accesses p er attempt, whic h leads to larger j -yields an d r educes the w orst-case n umb er of exp ensiv e up dates. Consequent ly , we can reduce the defin in g threshold b et w een Type B1 and Typ e B2 up dates, 2 W e also n eed to verify t hat k j ≥ 16 · c · ln n . As observed b efore, the dynamic algorithm will n ot increase its adv ance and chunk size v alues beyond O ( √ B ) implying 2 j = O ( √ B ). But then w e h a ve k j = 4 · n · B / 2 3 · j +5 = Ω( n/ √ B ) and n/ √ B ≥ n/ √ M ≥ n/ √ n ≥ 16 · c · ln n for sufficiently large n . ON DYNAMIC BREADTH-FIRST SEARCH IN EXTERNAL-MEMOR Y 559 th us even tually yielding b etter amortized I/O b oun ds. Details w e b e p ro vided in the full v ersion of this pap er. Mo difications along s im ilar li n es are in o r d er if external-memory is realiz ed b y flash disks [9]: compared to hard disks, fl ash memory can su stain man y more unstructur ed read I/Os p er second but on the other hand flash memory usually offers less read/write bandwidth th an hard disks. Hence, in algo rithm s lik e ours that are based on a trade-off b et ween un structured read I/Os and bulk r ead/write I/Os , p erformance can b e impro ve d b y allo wing more unstructur ed r ead I/Os (fetc hin g clusters) if this leads to less o verall I/O v olume (scannin g hot p o ol entries) . 7. Conclusions W e h a v e giv en the fir st non-trivial external-memory algorithm for dyn amic BFS. Ev en though we obtain significan tly b etter I/O b ounds than for the cu rrent ly b est static algo- rithm, ther e are a n umb er of op en problems: first of all, our b ound s dramatically d eteriorate for mixed up date sequences (edge in sertions and edge deletions in arbitrary order and p r o- p ortions); b esides oscillation effects, a s in gle edge deletion (insertion) ma y sp oil a w hole c hain of amortizations for p revious insertions (deletions). Also, it w ould b e interesting to see, w hether our b ounds can b e fu rther improv ed or also h old for shorter up date sequences. Finally , it would b e nice to come up with a deterministic version of the mo dified clustering. Ac kno wledgements W e wo uld lik e to th ank Deepak Ajw ani for v ery helpful d iscussions. References [1] A. Aggarwal and J. S . Vitter. The input/outpu t complexity of sorting and related problems. Commu- nic ations of the ACM, 31(9) , pages 1116–11 27, 1988. [2] L. Arge, G. Bro dal, and L. T oma. On external-memory MST, SS SP and multi-w a y planar graph sep- aration. In Pr o c. 8th Sc and. Workshop on Algorithmic The ory (SW A T) , volume 1851 of LNCS , pages 433–447 . Springer, 2000. [3] M. Ata llah and U. Vishkin. Fin d ing Euler tours in parallel. Journal of Computer and System Scienc es, 29(30) , pages 330–337, 1984. [4] A. Buc h sb aum, M. Goldw asser, S. V enka tasubramanian, and J. W es tb rook. O n ext ernal memory graph tra versal. I n Pr o c. 11th Ann. Symp osium on Discr ete Algor ithms (SODA) , pages 859–86 0. ACM-SIAM, 2000. [5] Y. J. Chiang, M. T. Go o drich, E. F. Gro ve, R. T amas ia, D. E. V engroff, and J. S. Vitter. External memory graph algorithms. In Pr o c. 6th Ann.Symp osium on Di scr ete Algor i thms (SODA) , pages 139– 149. ACM-SIAM, 1995. [6] T. H. Cormen, C.E. Leiserson, and R.L. Rivest. Intr o duction to Algorithms . McGraw-Hill, 1990. [7] C. Demetrescu, I. Finocchi, and A. Ribichini. T rading off space for passes in graph streaming problems. In 17th ACM-S I AM Symp osium on Discr ete Algorithms , pages 714–723, 2006. [8] D. Eppstein, Z. Galil, and G. Italiano. Dyn amic graph algorithms. I n Mikhail J. Atallah, editor, Algo- rithms and The ory of Computation Handb o ok , chapter 8. CRC Press, 1999. [9] E. Gal and S. T oledo. A lgorithms and data structures for flash memories. ACM Computing Surveys , 37:138– 163, 2005. [10] T. Hagerup and C. R ¨ ub. A guided tour of chernoff b ound s. Inf. Pr o c es s. L ett. , 33(6):305–308, 1990. [11] K. Mehlhorn and U. Meyer. Extern al-memory breadth -first search with sublinear I/O. In Pr o c. 10th Ann . Eur op e an Symp osium on Algorithms (ESA) , volume 2461 of LNCS , pages 723–7 35. Springer, 2002. 560 U. MEYER [12] U. Mey er, P . Sanders, and J. Sibeyn (Eds.). A lgorithms for Mem ory Hier ar chies , volume 2625 of LNCS . Springer, 2003. [13] K. Munagala and A. Ranade. I/O-complexity of graph algorithms. In In Pr o c. 10th Ann. Symp osium on Discr ete Algorithms (SOD A) , pages 687–694 . ACM - SIAM, 1999. [14] L. Ro ditty . Dynamic and static algorithms for p ath pr oblems in gr aphs . Ph D th esis, T el Av iv Universit y , 2006. [15] J. D. Ullman and M. Y annak akis. High-probability parallel transitiv e closure algorithms. SIAM Journal on Computing , 20(1):100– 125, F ebru ary 1991. [16] J. S. Vitter. External memory algo rithms and data structures: D ealing wi th massiv e data. ACM c omputing Surveys, 33 , pages 209–271 , 2001. Revised vers ion (A ugust 2007) av aila ble online at http://www .cs.purdue.edu/ho mes/jsv/Papers/Vit.IO survey.pdf . This wor k is license d unde r the Creative Commons Attr ibution-NoDer ivs License. T o v iew a copy of this license, visit http:/ /creativecommons.org/licenses/by- nd/3.0/ .
Original Paper
Loading high-quality paper...
Comments & Academic Discussion
Loading comments...
Leave a Comment