Faster Swap Edge Computation in Minimum Diameter Spanning Trees
Beat Gfeller ESA 2008
Presenters: 陳鵬仁 張凱崴 余相甫 徐國鐘 鄒承孝 沈 定 陳學毅
Outline
• Primitive Knowledge!!
• Failing on Diameter Edges
• Failing on Non-Diameter Edges
PRIMITIVE KNOWLEDGE!!
PRIMITIVE KNOWLEDGE!!
余相甫
MDST
• Given a simple graph
• Spanning Tree T
– Communication between nodes – Why trees?
• MDST
– Minimum Diameter Spanning Tree – Minimize the maximum travel time
G (V, E)
事事難料 Edge 會掉
• Edge e fails
– => 2 disconnect components
• Entire repair
– Find a new MDST on – May change many edges
• Ad hoc repair
– Construct only one new edge to connect – Swap Edge
T e
G e
e
f
Best Swap
• Edge e fails
– Many edges can connect 2 disconnect parts
• Best swap edge f
– Resulting tree with minimum diameter
• ABS
– All Best Swap – Find f e TE
Terminology
•
– 2-edge connected simple graph –
– : a spanning tree
• Edge weight
– l(e) : nonnegative
– d(x,y) : distance between x and y on the tree T
• Path
– –
G (V, E)
T (V,ET )
n | V | , m | E |
P p1,., pr
| P | d(p1, pr)
Terminology (Cont.)
• Diameter
– : diameter of tree T
• Subtree on T rooted at s
– : parent of x
– : subtree rooted at x – : child of x
,
(T) dS ,dE D
p(x)
Tx (V(Tx), E(Tx)) C(x)
Terminology (Cont.)
• Fail edge
– Denote by
• Swap edge
– Denote by
– Connect two disjoint parts – : all swap edges for e
e ET
f E \ ET F(e)
Terminology (Cont.)
•
– A spanning tree of
– : longest path contains f in – : longest path in
• Best swap edge f
– With respect to diameter – Minimize
T
e/ f (V,E
T\ {e} { f })
Pe/ f
(Te f/ )
D Te/ f
Te/ f G e
| (D Te f/ ) |
Terminology (Cont.)
• L(T,r)
– Length of longest path starts from r
• nc(v)
– the node on D(T) closest to v – Could be v itself
• nca(a,b)
– Nearest common ancestor of a and b
Terminology (conclude)
Formal Problem Definition:
• What we are given :
– G : two edge connected simple graph – T : a MDST of G
– D(T) : a diameter of T
• Objective:
– Find best swap edge f F(e) e ET
ABS: Previous Results
• Hassin, et al. (1997) find MDST in
–
• Nardelli, et al. (2001)
– Best swap tree diameter <= 5/2 diameter of entirely adjust tree
• Ito, et al. (2005)
– Time:
– Space:
O(n m) O(m)
O(mn n2 log n)
Main Result
• Solving ABS
– Time : – Space:
• Compare to Ito, et al.
– Better when m is smaller –
O(m log(n)) O(m)
m o( n2 log2n)
Main Idea
• Find candidate , and evaluate
– Quality of a swap edge f
• Present by me
– Case1:
• Diameter edges
– Case2:
• Non-diameter edges
e D(T ) e D(T )
f e T
Quality of Swap Edge
• Calculate efficiently
• Calculate efficiently
• Calculate L(T, r) efficiently
• Calculate efficiently
| (D Te f/ ) |
| Pe/ f |
d(a,b) a,b V
Lemma 1
•
–
• Proof:
– If does not contains f , D(T) is a diameter of T
• We will focus on from now
– Consider paths contain f only
e T and f F(e)
/ /
| (D Te f ) | max{| D( ) | |T , Pe f |}
(Te f/ ) D
| Pe/ f |
•
• contains three parts
– : f itself
– : a longest path start from u – : a longest path start from v
• Calculate
| P
e/ f|
| Pe/ f |
f (u,v)
in (1)ti
( T r , ) r O m e L
l( f )
(T e u , ) L
(T e v , ) L
e
u f
v
Lemma 2
• Let be a diameter of T
–
• Proof:
– We’ve already proved in exam !
• Calculate
– Recall that
D(T ) dS,,dE
, ( , ) { ( , S ), ( , E)}
r V T r max d r d d r d
L
d(a,b) a,b V
d(a,b) dT (a,b)
on a Tree
• We need to calculate
• Floyd-Warshall Algorithm
– preprocess time – space
– query time
d(a,b)
d(a,b) a,b V
O(n3) O(n2 )
O(1) a,b V
on a Tree (Cont.)
• We need to calculate
• Linear approach
– O(n) preprocess time – O(n) space
– O(1) query time
d(a,b)
d(a,b) a,b V
a,b V
d(a,b) on a Tree (Cont.)
• Root T at any node s
• A labeling of nodes allows nca(a,b)
– Preprocess within O(n) time and space – Answer any query within O(1)
– Implement by RMQ
• A labeling depth(x) – depth(x) = d(s, x)
– Implement by preorder traverse
d(a,b) on a Tree (Cont.)
• Let x = nca(a,b)
• d(a,b)
– From a to the nearest ancestor x – From x to b
• d(a,b) = d(a,x) + d(b,x)
– depth(a) + depth(b) – 2*depth (x) – O(1) query time
a
x
b s
Main Idea
• Find candidate , and evaluate
– Quality of a swap edge f
• Calculate efficiently
– Case1:
– Case2:
( ) eD T
( ) e D T
| De f/ |
f e T
FAILING ON DIAMETER EDGES
陳鵬仁 張凱崴
Failing on Diameter Edges
• We can solve this case in
– Time complexity O(m log n) – Space complexity O(m)
• How to find the longest path starting from r?
• Define nc(r) is the nearest node to r on diameter D(T)
r dE
nc(r) dS
Lemma 3
• Given a tree T = (V, ET), diameter D(T) with endpoints dS, dE, a failing edge e on D(T). For any node r, one of the longest path in T-e
starting from r contains nc(r).
• In other word, we must touch diameter before we arrive the furthest node.
r
dE nc(r)
e dS
r
dE nc(r)
e dS
• By contradiction
Prof. of Lemma 3
dS e
r z
nc(r)
x D(T)
• By contradiction
Prof. of Lemma 3
dS e
r z
nc(r)
x
How far can d
S/d
Ereach?
• Definition:
– μS(di, di+1)
• the longest path in T starting from dS without using edge (di,di+1)
– μE(di, di+1)
• the longest path in T starting from dE without using edge (di, di+1)
How far can d
S/d
Ereach?(cont.)
• μS(d0, d1) = μE(dk-1, dk) = 0
• μS(e) = μS(d3, d3+1) = 6
r
nc(r)
e dS=d0
d2 d3 d4 d5
d6 d7 = dE d1
How far can d
S/d
Ereach?(cont.)
• Claim that we can calculate μS, μE recursively in O(n)
• Define h(di): the length of a longest path starting in di, and not using any edges on the diameter D(T)
• h(di) for all di can be calculated in O(n) by doing DFS from an ambiguous root r on D(T)
h(d3) r
nc(r)
e dS=d0
d2 d3 d4 d5
d6 d7 = dE d1
How far can d
S/d
Ereach?(cont.)
• We can calculate μS, μE recursively in O(n)
• μS(d0, d1) = μE(dk-1, dk) = 0
• μS(di, di+1) = max{μs(di-1, di), d(dS, di)+h(di)}
• μE(di, di+1) = max{μE(di+1, di+2), d(dE, di+1)+h(di+1)}
• We have all h(di) in O(n), then all procedure will
finished in O(n) e
dS=d0
di-1 di di+1
h(di) μs(di-1, di),
How far can r reach?
• Lemma 4
• Given a diameter of T , D(T) = dS, d2, …, dE , a failing edge e = (di, di+1). The longest path on T - (di, di+1) starting from an ambiguous node r (if r is in the same subtree with dS) is
d(r, nc(r)) + max{d(nc(r), dS), μS(di, di+1) - d(nc(r), dS)}
or
d(r, nc(r)) + max{d(nc(r), dE), μE(di, di+1) - d(nc(r), dE)}
, if r is in the same subtree with dE
d(r, nc(r)) + max{d(nc(r), dS), μS(di, di+1) - d(nc(r), dS)}
dS=d0 e
nc(r) d
i di+1
μs(di-1, di)
r d(r, nc(r))
d(r, nc(r)) + max{d(nc(r), dS), μS(di, di+1) - d(nc(r), dS)}
• By Lemma 3, the longest path from r must reach nc(r) first. We can observe the following two cases.
• If the furthest path from r is toward to dS at nc(r)
dS=d0 nc(r) di e di+1
μs(di-1, di)
r d(r, nc(r)) dS=d0 nc(r) di e di+1
μs(di-1, di)
r
d(nc(r), dS) > μS(di, di+1) - d(nc(r), dS)
d(nc(r), dS) > μS(di, di+1) - d(nc(r), dS)
• By Lemma 3, the longest path from r must reach nc(r) first. We can observe the following two cases.
• If the furthest path from r is toward to dE at nc(r)
dS=d0 nc(r) di e di+1
μs(di-1, di)
r d(r, nc(r)) dS=d0 nc(r) di e di+1
μs(di-1, di) r
d(nc(r), dS) < μS(di, di+1) - d(nc(r), dS)
d(r, nc(r)) + max{d(nc(r), dS), μS(di, di+1) - d(nc(r), dS)}
Find for all
R96922050 張凱崴
Four Cases of
+ + + +
Observations on Different
is independent of
An Intuition of Finding
+ + + +
An Intuition of Finding
+ + + +
+ + + +
Observations on different
The Definition of
Virtual Edge (I)
+ + + +
Virtual Edge (II)
+ + + +
Construct Virtual Edges
Find Maximal vitual edges of the 4 cases for all in
+ + + +
Consider only
+
2 1
3 4
6 5 7
9 8
Heap ( ) = {1,3,5,9 }
Using Heap to Find Maximal For each
2 1
3 4
6 5 7
9 8
Heap ( ) = { }
+
Using Heap to Find Maximal For each
2 1
3 4
6 5 7
9 8
Heap ( ) = { 2,6,9 }
+
Using Heap to Find Maximal For each
2 1
3 4
6 5 7
9 8
Heap ( ) = {2,5,6,9 }
+
Using Heap to Find Maximal For each
+
2 1
3 4
6 5 7
9 8
Heap ( ) = {3,5,6,9 }
Using Heap to Find Maximal For each
+
2 1
3 4
6 5 7
9 8
Heap ( ) = {1,3,5,9 }
[Algorithm] Step 1
• Construct virtual edges
+ + + +
[Algorithm] Step 2
• Using 4 heap to find maximal virtual edges of the 4 cases for all in
+ + + +
2 1
3 4
6 5 7
9 8
[Algorithm] Step 3
+ + + + +
+ + +
• Compare the 4 virtual edge of each
FAILING ON NON-DIAMETER EDGES
陳學毅 鄒承孝 沈 定 徐國鐘
Swap Edges for Failing Non-diameter Edges
• Choose a vertex r in the diameter of T as root of T.
• We first consider the swap edge which is a backedge.
• let f = (u, v) be an edge not in tree T s.t. u is a descendant of v in T.
• We called such edge f as a backedge.
• Hence, f could be the backup edge for each edge on the path from v to u in T.
Backedge f = (u, v)
• Let the path in T from v to u is (e1, … , ek)
• Assume ei is the failing edge.
• The part with v will also contain D(T).
Hence L(T-ei,v) = L(T,v).
Midpoint Edge
• Midpoint is on the D(T) such that midpoint has equal length to the two endpoint of D(T). (mid point may lie on an edge)
• The edge contains midpoint is called midpoint edge. (if there may be more than one midpoint edge, any of them can be chosen)
• By Lemma 2, for any vertex v, the longest path start on one side of the midpoint edge and go to the opposite end of the diameter.
For some failing edge e
• Let e = (p(x),x), f = (u,v)
• Let (p(h),h) be the midpoint edge in Tx
• By Lemma 2, all longest path in Tx will contains (p(h), h).
Swap edge e by f
• In the same part with v, it also contains D(T).
• The only path changed in T – e + f are the paths which contain the edge f = (u,v)
Group the Swap Edge Candidate
• Group such backedge by their endpoint in Tx
Lemma 6
• Lemma 6 : In any group, a best swap candidate for failing edge e is a swap edge f = (u,v) s.t.
L(T,v) + l(f) + depth(u) is minimum.
Lemma 6 (continued)
• In order to compare the swap candidate
between different group, we need to modify the value before to be more precise to the longest path pass (u,v).
Lemma 6 (continued)
• Let nca(u,h) = w
• L(T,v) + l(f) + (depth(u) – depth(w)) + d(w,vdeep)
• vdeep is the endpoint of D(Tx) in Th
Relation between groups
R97922063 鄒承孝
Relation between Groups
• Lemma 7. Let e = (x, p(x)) and c ∈ C(x).
• If midpoint edge of D(Tx) is (c, x) or ∈ Tc.
• Then, midpoint edge of D(Tx) path from ∈ midpoint edge of D(Tc) to e.
Midpoint edge of D(Tc)
c x
Midpoint edge of D(Tx) lies on this path
Proof
• Case 1: midpoint edge of D(Tx) is (c, x)
– Straightforward.
• Case 2: midpoint edge of D(Tx) ∈ Tc
– (h, p(h)): midpoint edge of D(Tx)
– T’ and T”: subtrees by deleting (h, p(h)) from Tc, where h ∈ T’ and p(h) ∈ T”, respectively.
Proof (concluded)
• Case 2: midpoint edge of D(Tx) ∈ Tc
– Assume otherwise, then midpoint edge of D(Tc) ∈ T”.
– By definition, farthest vertex of p(h) in Tx ∈ T’.
– Similarly, farthest vertex of p(h) in Tc ∈ T”.
– But farthest vertex of p(h) in Tx is farthest vertex of p(h) in Tc or farthest vertex of p(h) in Tx – Tc,
neither is ∈ T’.
– Contradiction!
Relation between Groups
• Midpoint edge moves “upwards”.
• So the relation between groups of swap edges can be established.
Relation between Groups
• (h, p(h)): midpoint edge of D(Tx)
• (g, p(g)): midpoint edge of D(Tc)
• start-at(x): swap edges with lower endpoint = x
• end-at(x): swap edges with upper endpoint = x
• q ∈ C(x) and q ≠ c
• Gupper(x, x) = start-at(x) ∪ {∪q GR(q)} \
end-at(x)
p(x)
G
upper(x, x)
… x c
G
upper(x, w)
• w path form ∈ p(h) to c
• Gupper(x, w) = Gupper(c, w) \ end-at(x)
• Recursive definition.
p(x)
… x c
p(h) w…
G
lower(x)
• d path from ∈ p(g) to h
• Glower(x) = Glower(c) ∪ {∪d Gupper(q)} \ end-at(x)
• Recursive definition
p(x)
… x c
g
Glower(c)
…
h
p(g)
5.2 Data Structure and Inductive Approach
沈 定
Preprocessing Step
Preprocessing Step
Preprocessing Step
Main Algorithm
Main Algorithm
Main Algorithm
Result
Transforming Non-tree Edges to Backedges
徐國鐘
If swap edges ≠ backedges
• We now describe to replace any edge f by at most two “virtual” backedges , whose lengths are defined in such a way that the best swap edge computed by our algorithm is correct.
Replacement
• Replace f = (u, v) by f1 := (u, v1) and f2 := (v, u2)
– with lengths
l(f1) := l(f) + d(v, v1) l(f2) := l(f) + d(u, u2)
• If the path from u to v in T uses one or more edges of D(T)
– define v1 := nc(u) and u2 := nc(v).
• Otherwise
– we define v1 := nca(u, v) and u2 := nca(u, v).
Case 1
dE u2=nc(v)
f dS
f1 f2
v u
v1=nc(u) D(T)
l(f1) := l(f) + d(v, v1) l(f2) := l(f) + d(u, u2)
Case 2
dE
f dS
f1 f2
v u
D(T)
l(f1) := l(f) + d(v, v1) l(f2) := l(f) + d(u, u2)
Reasons
• Reason
– f1 represents f exactly for all failing edges on the path in T from u to v1, and f2 represents f exactly for all edges from v to u2
– for each non-diameter tree edge, one of f1, f2 represents f
• The lengths of f1 and f2 are defined exactly
such that for any failing edge e for which fi is a swap edge, it holds |D(Te/fi )| = |D(Te/f )|.
Revealing figure
dE u2=nc(v)
f dS
f1 f2
v u
v1=nc(u) D(T)
e
Revealing figure: Case 1_1
l(f1) := l(f) + d(v, v1)
dE u2
f dS
v u
v1 D(T)
e dE
u2 dS
f1
v u
v1 D(T)
e
Revealing figure: Case 1_2
f
v u
e
f1
v u
e
l(f1) := l(f) + d(v, v1) l(f1) := l(f) + d(v, u2)-d(u2,v1)
Revealing figure: Case 1_3
l(f1) := l(f) + d(v, v1) l(f1) := l(f) + d(v, u2)-d(u2,v1)
dE u2
f dS
v u
v1 D(T)
e
u2 dS
f1
v u
D(T)
e dE
v1
Comment
• The proof is not closed yet.
• Possible solution in the Case 1_3
– |Pe/f|<=|DT| may be always true for the case.
– Try to face crossing edges instead of using replacement.
• The typo is terrible.
11/03/2022 98