• Aucun résultat trouvé

Partially Dynamic Problems on Undirected Graphs

Dans le document ALGORITHMS and THEORY of COMPUTATION HANDBOOK (Page 187-190)

Dynamic Graph Algorithms

8.4 Partially Dynamic Problems on Undirected Graphs

For undirected graphs, most of thepartially dynamic problemsconsidered are incremental, namely they support edge insertions only. We first show how to maintain a minimum spanning forest when the underlying graphGis subject to insertions of edges. We represent eachtree in the minimum spanning forest as a dynamic tree (as defined in Section 8.3). Lete=(x, y)be the edge to be inserted, and letFbe a minimum spanning forest ofGbefore insertinge. If the endpoints ofeare in two different connected components ofG, then the new forestFwill beF ∪ {e}. Note that all this can be done inO(logn) worst-case time with the dynamic trees: we find the root ofx, th e root ofy, and then link the two trees.

Otherwise,xandyare in the same tree of the forestF, and insertingeinF introduces one cycleλ. To compute the new spanning forestFwe apply the cycle property inλas follows. LetT be th e tree ofF containing bothxandy: perform an evert onT and root it atx. Next, find the maximum cost edgefin the path fromyto the root. If the cost ofeis greater than the cost off, th enF=F. Otherwise, swape andf. Note that again this implies a constant number of operations to be executed on a forest of dynamic trees and therefore can be accomplished inO(logn)worst-case time.

THEOREM 8.2 A minimum spanning forest of a graphGsubject to edge insertions only can be maintained inO(logn)worst-case time per operation, wherenis the number of vertices inG.

The previous theorem gives implicitly an incremental algorithm for maintaining the connected com-ponents of a graph, since a minimum spanning forest ofGis trivially a spanning forest ofG(we assume that each edge has cost 1). A query on whether two verticesxandyare in a same connected component can be answered inO(logn)time by finding and comparing the roots ofxandy. A better bound can

be achieved by representing the trees in the forest using the set union data structures of Chapter 5. A query on wh eth er two verticesxandyare connected can be answered by checking whetherfind(x)equals find(y). When inserting edgee= (x, y), we first performAfind(x)andBfind(y). IfA = B, xandywere already connected and the insertion ofedoes not change the connected components ofG.

IfA=BthenAandBhave to be merged into a new connected component: we do this by executing a union(A, B). Since eachoperation can be implemented by a constant number of set union operations, we have the following theorem.

THEOREM 8.3 The connected components a graphGsubject to edge insertions only can be maintained in O(α(q, n))amortized time per query or update operation, whereqis the total number of queries andnis the number of vertices inG.

Set union data structures can be used for the partially dynamic maintenance of other graph properties, such as bipartiteness, and edge and vertex connectivity. For lack of space, we describe here only how to solve the partially dynamic 2-edge connectivity problem. This problem consists of maintaining a graph Gunder an intermixed sequence of operations of the following kinds.

Same2EdgeBlock(u, v): Returntrueif verticesuand v are in the same 2-edge-connected component. Returnfalseotherwise.

InsertEdge(x, y):Insert a new edge between the two verticesxandy.

Westbrook and Tarjan [44] presented one algorithm that runs in a total ofO(qα(q, n))time, whereq is the total number ofSame2EdgeBlockandInsertEdgeoperations, andnis the number of vertices. For sake of simplicity, we describe in details only the algorithm that operates on connected graphs, and refer the interested reader to [44] for the full details of the method on general unconnected graphs.

For any vertexxinGdenote byC2E(x)the 2-edge-connected component ofGcontainingx. Th e main data structure maintained by the algorithm is the bridge-block tree ofG, which is defined as follows.

Nodes in this tree correspond to 2-edge-connected components ofG, and any two nodes are connected by an edge if and only if there is a bridge connecting the corresponding 2-edge-connected components.

We assume that the bridge-block tree is rooted arbitrarily at one node, and we denote byparent(σ)the parent of a tree nodeσin the bridge-block tree.

Besides maintaining the bridge-block tree ofG, we maintain the actual 2-edge-connected components ofGas disjoint sets, subject tounionandfindoperations. For this, we use any of the fast set-union data structures described in Chapter 5, which are able to process any sequence ofqunionandfindoperations on a collection ofnelements inO(qα(q, n))worst-case time.

We define the name of each disjoint set in the set-union data structure as a pointer to the tree node associated to the corresponding 2-edge-connected component. Thus, we can assume that for each vertex xinG,find(x)=C2E(x). Withthis data structure, aSame2EdgeBlock(x, y)can be simply performed by checking whetherfind(x)=find(y). Theunionoperations will be used to update efficiently the 2-edge-connected components duringInsertEdgeoperations. The effect of anInsertEdge(u, v)on the bridge-block tree depends on whetheruandvare in the same connected component or in different 2-edge-connected components. LetC2E(u)andC2E(v)be the 2-edge-connected components containinguand v, respectively, before inserting the edge(u, v).

We now describe the changes caused in the bridge-block tree by the insertion of edge(u, v). IfC2E(u)= C2E(v), the bridge-block tree is unaffected by the new edge and hence, no change is needed in the data structure. IfC2E(u)=C2E(v), the inserted edge creates a new cycle that reduces the number of 2-edge-connected components and bridges ofG. This cycle consists of(u, v)plus all the edges in the tree path between nodeC2E(u)and nodeC2E(v). All the nodes in this tree path must be replaced by a single node, and every node previously adjacent to one of the nodes in the tree path becomes adjacent to the new single node. This process is calledpath condensation.

To implementInsertEdgeoperations, the bridge-block tree is maintained as a data structure that supports the following primitives:

FindPath(σ1, σ2):Given two tree nodesσ1andσ2, return the tree path betweenσ1andσ2. If σ1=σ2 =σ, returnσ.

CondensePath(π):Perform pathcondensation on the tree pathπ, unioning the corresponding disjoint sets associated with the encountered tree nodes. Return the modified bridge-block tree. Note that aCondensePathdoes nothing ifπis an empty pathconsisting of a single node.

AFindPath(σ1, σ2)can be implemented as follows: we proceed fromuand fromvtoward the tree root, alternating one step at the time, until the paths traced fromuand fromvintersect at their nearest common ancestor. Note that this returns the nearest common ancestor ofuandv, and the tree pathπbetweenu andv. The number of steps required to returnπis at most 2|π|. Since they are performed by following parent pointers, we call theseparent steps.The pathπis returned as a list of nodes (not in order along the path), with the nearest common ancestor at the end. Letσbe the parent of the nearest common ancestor.

To perform aCondensePath(π),πis condensed into a single nodeσ, which is made child ofσ. All the disjoint sets associated withnodes inπare unioned. Since we perform a union at eachstep, we call these union steps.

LEMMA 8.3 In any sequence of operations, there are at mostO(n)parent and union steps.

PROOF Suppose a pathπis being condensed. To generateπ,O(|π|)parent steps are required, and

|π| −1 nodes are condensed. Since after(n−1)condensations the graph becomes 2-edge-connected, there can be at mostO(n)parent steps and(n−1)union steps.

With the help of these primitives, we support anInsertEdge(u, v)as follows:

InsertEdge(u, v)begin

returnCondenseP ath(F indP ath(f ind(u), f ind(v)));

end

THEOREM 8.4 [44]Given an initially connected graphG0=(V0, E0)andO(|E0|)preprocessing time, a sequence ofqInsertEdgeandSame2EdgeBlockoperations can be processed inO(qα(q, n))time.

PROOF The 2-edge-connected components and the bridge-block tree ofG0can be found inO(|E0|) using the algorithm of Tarjan [43]. By Lemma 8.3, the total number of parent and union steps isO(n), giving a total ofO(q)finds andO(n)unions in the set union data structure.

To complete this section, we mention that most of the incremental algorithms proposed in the literature for edge and vertex connectivity (see, e.g.,[5, 6, 17, 29, 31, 32, 44]) follow the approach outlined here for 2-edge connectivity. Namely, connectivity queries are answered by maintaining a tree that reflects th e structure of th e connectivity cuts of th e graph . Wh en a new edge(u, v)is added to th e graph , some connectivity cuts may be invalidated; these connectivity cuts can be easily found since they all lie in a tree path, whose endpoints correspond touandv. After locating the path, some form of path condensation takes place. To support efficiently pathcondensation, set-union based data structures are used. The tree structure of the(k−1)-cuts is fairly complicated, however, askincreases, and it requires sophisticated data structures and a quite delicate analysis.

Dans le document ALGORITHMS and THEORY of COMPUTATION HANDBOOK (Page 187-190)