• 沒有找到結果。

Faster Swap Edge Computation in Minimum Diameter Spanning Trees

N/A
N/A
Protected

Academic year: 2022

Share "Faster Swap Edge Computation in Minimum Diameter Spanning Trees"

Copied!
99
0
0

加載中.... (立即查看全文)

全文

(1)

Faster Swap Edge Computation in Minimum Diameter Spanning Trees

Beat Gfeller ESA 2008

Presenters: 陳鵬仁 張凱崴 余相甫 徐國鐘 鄒承孝 沈 定 陳學毅

(2)

Outline

Primitive Knowledge!!

Failing on Diameter Edges

Failing on Non-Diameter Edges

(3)

PRIMITIVE KNOWLEDGE!!

PRIMITIVE KNOWLEDGE!!

余相甫

(4)

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)

(5)

事事難料 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

(6)

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

(7)

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)

(8)

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)

(9)

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)

(10)

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/ ) |

(11)

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

(12)

Terminology (conclude)

(13)

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

(14)

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)

(15)

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)

(16)

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

(17)

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

(18)

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 |

(19)

• 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

(20)

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)

(21)

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

(22)

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

(23)

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

(24)

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

(25)

Main Idea

• Find candidate , and evaluate

Quality of a swap edge f

Calculate efficiently

Case1:

Case2:

( ) eD T

( ) e D T

| De f/ |

f e T

(26)

FAILING ON DIAMETER EDGES

陳鵬仁 張凱崴

(27)

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

(28)

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.

(29)

r

dE nc(r)

e dS

(30)

r

dE nc(r)

e dS

(31)

• By contradiction

Prof. of Lemma 3

dS e

r z

nc(r)

x D(T)

(32)

• By contradiction

Prof. of Lemma 3

dS e

r z

nc(r)

x

(33)

How far can d

S

/d

E

reach?

• 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)

(34)

How far can d

S

/d

E

reach?(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

(35)

How far can d

S

/d

E

reach?(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

(36)

How far can d

S

/d

E

reach?(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),

(37)

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

(38)

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))

(39)

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)

(40)

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)}

(41)

Find for all

R96922050 張凱崴

(42)

Four Cases of

+ + + +

(43)

Observations on Different

is independent of

(44)

An Intuition of Finding

+ + + +

(45)

An Intuition of Finding

+ + + +

+ + + +

(46)

Observations on different

(47)

The Definition of

(48)

Virtual Edge (I)

+ + + +

(49)

Virtual Edge (II)

+ + + +

(50)

Construct Virtual Edges

(51)

Find Maximal vitual edges of the 4 cases for all in

+ + + +

(52)

Consider only

+

2 1

3 4

6 5 7

9 8

Heap ( ) = {1,3,5,9 }

(53)

Using Heap to Find Maximal For each

2 1

3 4

6 5 7

9 8

Heap ( ) = { }

+

(54)

Using Heap to Find Maximal For each

2 1

3 4

6 5 7

9 8

Heap ( ) = { 2,6,9 }

+

(55)

Using Heap to Find Maximal For each

2 1

3 4

6 5 7

9 8

Heap ( ) = {2,5,6,9 }

+

(56)

Using Heap to Find Maximal For each

+

2 1

3 4

6 5 7

9 8

Heap ( ) = {3,5,6,9 }

(57)

Using Heap to Find Maximal For each

+

2 1

3 4

6 5 7

9 8

Heap ( ) = {1,3,5,9 }

(58)

[Algorithm] Step 1

• Construct virtual edges

+ + + +

(59)

[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

(60)

[Algorithm] Step 3

+ + + + +

+ + +

• Compare the 4 virtual edge of each

(61)

FAILING ON NON-DIAMETER EDGES

陳學毅 鄒承孝 沈 定 徐國鐘

(62)

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.

(63)

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).

(64)

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.

(65)

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).

(66)

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)

(67)

Group the Swap Edge Candidate

• Group such backedge by their endpoint in Tx

(68)

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.

(69)

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).

(70)

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

(71)

Relation between groups

R97922063 鄒承孝

(72)

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

(73)

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.

(74)

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!

(75)

Relation between Groups

• Midpoint edge moves “upwards”.

• So the relation between groups of swap edges can be established.

(76)

Relation between Groups

• (h, p(h)): midpoint edge of D(Tx)

• (g, p(g)): midpoint edge of D(Tc)

(77)

• 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

(78)

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

(79)

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)

(80)

5.2 Data Structure and Inductive Approach

沈 定

(81)

Preprocessing Step

(82)

Preprocessing Step

(83)

Preprocessing Step

(84)

Main Algorithm

(85)

Main Algorithm

(86)

Main Algorithm

(87)

Result

(88)

Transforming Non-tree Edges to Backedges

徐國鐘

(89)

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.

(90)

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).

(91)

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)

(92)

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)

(93)

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 )|.

(94)

Revealing figure

dE u2=nc(v)

f dS

f1 f2

v u

v1=nc(u) D(T)

e

(95)

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

(96)

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)

(97)

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

(98)

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

(99)

Finis

參考文獻

相關文件

We solve the three-in-a-tree problem on

vertices’ edges, in this shortest path, the left edge must be relaxed before the right edge.  One phase of improvement

 Calculating the expected total edge number for one left path started at one problem with m’ edges.  Evaluating the total edge number for all right sub-problems #

volume suppressed mass: (TeV) 2 /M P ∼ 10 −4 eV → mm range can be experimentally tested for any number of extra dimensions - Light U(1) gauge bosons: no derivative couplings. =&gt;

• Formation of massive primordial stars as origin of objects in the early universe. • Supernova explosions might be visible to the most

Given a connected graph G together with a coloring f from the edge set of G to a set of colors, where adjacent edges may be colored the same, a u-v path P in G is said to be a

(Another example of close harmony is the four-bar unaccompanied vocal introduction to “Paperback Writer”, a somewhat later Beatles song.) Overall, Lennon’s and McCartney’s

Given an undirected graph with nonnegative edge lengths and nonnegative vertex weights, the routing requirement of a pair of vertices is assumed to be the product of their weights.