Unformatted text preview:

MIT OpenCourseWarehttp://ocw.mit.edu 6.854J / 18.415J Advanced Algorithms Fall 2008��For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms.1 18.415/6.854 Advanced Algorithms September 29, 2008 Lecture 7 - Dynamic Trees Lecturer: Michel X. Goemans Overview In this lecture, we discuss dynamic trees, a sophisticated data structure intro duced by Sleator and Tarjan. Dynamic trees allow to provide the fastest worst-case running times for many network flow algorithms. In particular, it will allow us to efficiently perform the Cancel operation in the Cancel and Tighten algorithm. Dynamic trees build upon splay trees, which we introduced in the previous lecture. Dynamic trees ma nage a set of node-disjoint (not necessarily binary) rooted trees. With each node v is associated a cost. In our use of dynamic trees, the cost will be coming from the edge (p(v), v), where p(v) denotes the parent of v; the cost of the root in that case will be set arbitrarily large (larger than the cost of any other node), say +∞. Figure 1: Example of Dynamic Tree. Dynamic trees will support the following operations: • make-tree(v): Creates a tree with a single node v, whose cost is +∞. • find-root(v): Finds and returns the root of the tree c ontaining the node v. • find-cost(v): Returns the cost of node v. (This may sound like a trivial op e ration, but in fact there is real work to be done, because we will not explicitly maintain the costs of all nodes.) • find-min(v): Finds and returns the ancestor of w of v with minimum cost. Ties go to the node closest to the root. • add-cost(v, x): Adds x to the cost of all nodes w on the path from find-root(v) to v. • cut(v): Brea ks the rooted tree in two by removing the link to v from its parent. The node v is now the root of a new tree, and its cost is set to +∞. • link(v, w, x): Ass umes that (1) w is a root, and (2) v and w are not in the same tree, i.e. find-root(v) 6 w. Combines two trees by adding an edge (v, w), i.e. p(w) = v.= Sets the c ost of w equal to x. We will later show that all of these ope rations run in O(log n) amortized time. 7 - Dyna mic Trees-12 v v Figure 2: cut(v) operation. LINK W V COST(W) = X Figure 3: link(v, w, x) operation. Theorem 1 The total running time of any sequence of m dynamic tree operations is O((m + n) log n), where n is the number of nodes. We defer the proof o f this theorem until the next lecture. Implementation of Cancel with dynamic trees Recall the setting for the Cancel step in the a lgorithm Cancel and Tighten for the minimum cost flow problem. We have a circulation f and node potentials p in an instance defined on graph G. Recall that an edge (v, w) is admiss ible if cp(v, w) < 0, and the admissible graph (V, Ea), is the subgraph o f Ef (the residual graph corresponding to our circulation) containing only the admissible edges. Our aim is to repeatedly find a cycle in the admissible graph and saturate it. Each time we do this, all of the satur ated edges disappear from the graph. Also recall that no edges are added to the admissible graph during this process, bec ause any new edge in the residual graph must have positive reduced c ost and are therefore is not admissible. We repr e sent the problem with dynamic trees, wher e the nodes in the dynamic trees correspond to nodes in G and the edges of the dynamic trees are a subset of the admissible edges. We maintain two (disjoint) sets of admissible edges: those which are currently in the dynamic tree, and those which still need to be considered. The cost of a node v will correspond to the residual capac ity uf (p(v), v) of the edge (p(v), v), unless v is a root node, in which cas e it will have cost +∞. We will also mark s ome of the roots (denoted graphically with a (∗)) to indicate that we dea lt with them and concluded they can’t be part of any cycle. For the edges not in the dynamic tree, we also maintain the flow value. (We don’t need to maintain the flow e xplicitly for the edges in the trees, since we can recover the flow from the edge capacities in G and the residual capacity.) To summarize, we begin with a set of n singleton trees. All of the edges sta rt out in the remaining pool. In each iter ation, we try to find an admissible edge leading to the root r of one of the dynamic trees. If we fail to find such an edge, this implies there are no admissible cycles which include r, 7 - Dyna mic Trees-2and so we mark it and remove it from consideration. Suppose, on the other hand, that we do find an edge (w, r) leading into the root. If w is in a different tree , we join the two trees by adding an edge connecting w and r. On the other hand, if w and r are part of the same tree, it means we have found a cycle. In this case, we push flow along the cycle and remove the saturated e dges from the data structure. In more detail, we keep repeating the following pr ocedure as long as there still exist unmarked roots: ⊲ Choose an unmarked root r. ⊲ Among admissible edges, try to find one which leads to r. ⊲ CASE 1: there is no s uch (v, r) ∈ Ea. ⊲ Mark r, since we know it cannot possibly be part of a cycle. ⊲ Cut all the children v of r. ⊲ Set f(r, v) ← u(r, v) − uf (r, v) = u(r, v) − find-cost(v) ⊲ CASE 2: there is an admiss ible edge (w, r) from a different tree, i.e. find-root(w) =6r. ⊲ Link the two trees: link(w, r, u(w, r) − f(w, r)) ⊲ CASE 3: there is an admissible edge (w, r) fro m the same tree, i.e. find-root(w) = r. ⊲ We’ve found a cy c le, so push flow along the cycle. The amount we ca n pus h is δ = min(u(w, r) − f(w, r), find-cost(find-min(w))) ⊲ add-cost(w, −δ)


View Full Document

MIT 6 854 - Lecture 7 - Dynamic Trees

Download Lecture 7 - Dynamic Trees
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture 7 - Dynamic Trees and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture 7 - Dynamic Trees 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?