csce 411 design and analysis of algorithms

44
CSCE 411 Design and Analysis of Algorithms Set 13: Link Reversal Routing Prof. Jennifer Welch Spring 2012 CSCE 411, Spring 2012: Set 13 1

Upload: primo

Post on 03-Feb-2016

32 views

Category:

Documents


0 download

DESCRIPTION

CSCE 411 Design and Analysis of Algorithms. Set 13: Link Reversal Routing Prof. Jennifer Welch Spring 2012. Routing [Gafni & Bertsekas 1981]. Undirected connected graph represents communication topology of a distributed system computing nodes = graph vertices - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: CSCE 411 Design and Analysis of Algorithms

CSCE 411Design and Analysis

of Algorithms

Set 13: Link Reversal RoutingProf. Jennifer Welch

Spring 2012

CSCE 411, Spring 2012: Set 13 1

Page 2: CSCE 411 Design and Analysis of Algorithms

Routing [Gafni & Bertsekas 1981]

Undirected connected graph represents communication topology of a distributed system

computing nodes = graph vertices message channels = graph edges

Unique destination node in the system Assign virtual directions to the graph edges (links)

s.t. if nodes forward messages over the links, they reach the

destination Directed version of the graph must

be acyclic have destination as only sink

Thus every node has a path to destination. 2CSCE 411, Spring 2012: Set 13

Page 3: CSCE 411 Design and Analysis of Algorithms

Routing Example

3

D

1 2 3

4 5 6CSCE 411, Spring 2012: Set 13

4 wants tosend a msgto D

Page 4: CSCE 411 Design and Analysis of Algorithms

Mending Routes What happens if some edges go away?

Might need to change the virtual directions on some remaining edges (reverse some links)

More generally, starting with an arbitrary directed graph, each vertex should decide independently which of its incident links to reverse

4CSCE 411, Spring 2012: Set 13

Page 5: CSCE 411 Design and Analysis of Algorithms

Mending Routes Example

5

D

1 2 3

4 5 6CSCE 411, Spring 2012: Set 13

Page 6: CSCE 411 Design and Analysis of Algorithms

Sinks A vertex with no outgoing links is a

sink. The property of being a sink can be

detected locally. A sink can then reverse some incident

links Basis of several algorithms…

6CSCE 411, Spring 2012: Set 13

Page 7: CSCE 411 Design and Analysis of Algorithms

Full Reversal Routing Algorithm Input: directed graph G with

destination vertex D Let S(G) be set of sinks in G other

than D while S(G) is nonempty do

reverse every link incident on a vertex in S(G)

G now refers to resulting directed graph

7CSCE 411, Spring 2012: Set 13

Page 8: CSCE 411 Design and Analysis of Algorithms

Full Reversal (FR) Routing Example

8

D

1 2 3

4 5 6

D

1 2 3

4 5 6

D

1 2 3

4 5 6

D

1 2 3

4 5 6

D

1 2 3

4 5 6

D

1 2 3

4 5 6

CSCE 411, Spring 2012: Set 13

Page 9: CSCE 411 Design and Analysis of Algorithms

Why Does FR Terminate? Suppose it does not. Let W be vertices that take infinitely many steps. Let X be vertices that take finitely many steps;

includes D. Consider neighboring vertices w in W, x in X. Consider first step by w after last step by x: link

is w x and stays that way forever. Then w cannot take any more steps,

contradiction.

9CSCE 411, Spring 2012: Set 13

Page 10: CSCE 411 Design and Analysis of Algorithms

Why is FR Correct? Assume input graph is acyclic. Acyclicity is preserved at each iteration:

Any new cycle introduced must include a vertex that just took a step, but such a vertex is now a source (has no incoming links)

When FR terminates, no vertex, except possibly D, is a sink.

A DAG must have at least one sink: if no sink, then a cycle can be constructed

Thus output graph is acyclic and D is the unique sink.

10CSCE 411, Spring 2012: Set 13

Page 11: CSCE 411 Design and Analysis of Algorithms

Pair Algorithm Can implement FR by having each vertex v

keep an ordered pair (c,v), the height (or vertex label) of vertex v c is an integer counter that can be incremented v is the id of vertex v

View link between v and u as being directed from vertex with larger height to vertex with smaller height (compare pairs lexicographically)

If v is a sink then v sets c to be 1 larger than maximum counter of all v’s neighbors

11CSCE 411, Spring 2012: Set 13

Page 12: CSCE 411 Design and Analysis of Algorithms

Pair Algorithm Example

12

0

1 2 3

(0,2)(0,1)

(1,0)

(2,3)(2,1)

CSCE 411, Spring 2012: Set 13

Page 13: CSCE 411 Design and Analysis of Algorithms

Pair Algorithm Example

13

0

1 2 3

(0,2)(0,1)

(1,0)

(2,3)(2,1) (3,2)

CSCE 411, Spring 2012: Set 13

Page 14: CSCE 411 Design and Analysis of Algorithms

Pair Algorithm Example

14

0

1 2 3

(0,2)(0,1)

(1,0)

(2,3)(2,1) (3,2)

CSCE 411, Spring 2012: Set 13

Page 15: CSCE 411 Design and Analysis of Algorithms

Partial Reversal Routing Algorithm

Try to avoid repeated reversals of the same link.

Vertices keep track of which incident links have been reversed recently.

Link (u,v) is reversed by v iff the link has not been reversed by u since the last iteration in which v took a step.

15CSCE 411, Spring 2012: Set 13

Page 16: CSCE 411 Design and Analysis of Algorithms

Partial Reversal (PR) Routing Example

16

D

1 2 3

4 5 6

D

1 2 3

4 5 6

D

1 2 3

4 5 6

D

1 2 3

4 5 6

D

1 2 3

4 5 6

D

1 2 3

4 5 6

CSCE 411, Spring 2012: Set 13

Page 17: CSCE 411 Design and Analysis of Algorithms

Why is PR Correct? Termination can be proved similarly

as for FR: difference is that it might take two steps by w after last step by x until link is w x .

Preservation of acyclicity is more involved, deferred to later.

17CSCE 411, Spring 2012: Set 13

Page 18: CSCE 411 Design and Analysis of Algorithms

Triple Algorithm Can implement PR by having each vertex v keep an

ordered triple (a,b,v), the height (or vertex label) of vertex v a and b are integer counters v is the id of vertex v

View link between v and u as being directed from vertex with larger height to vertex with smaller height (compare triples lexicographically)

If v is a sink then v sets a to be 1 greater than smallest a of all its neighbors sets b to be 1 less than smallest b of all its neighbors with new

value of a (if none, then leave b alone)

18CSCE 411, Spring 2012: Set 13

Page 19: CSCE 411 Design and Analysis of Algorithms

Triple Algorithm Example

19

0

1 2 3

(0,0,2)(0,0,1)

(0,1,0)

(0,2,3)(1,0,1)

CSCE 411, Spring 2012: Set 13

Page 20: CSCE 411 Design and Analysis of Algorithms

Triple Algorithm Example

20

0

1 2 3

(0,0,2)(0,0,1)

(0,1,0)

(0,2,3)(1,0,1) (1,-1,2)

CSCE 411, Spring 2012: Set 13

Page 21: CSCE 411 Design and Analysis of Algorithms

Triple Algorithm Example

21

0

1 2 3

(0,0,2)(0,0,1)

(0,1,0)

(0,2,3)(1,0,1) (1,-1,2)

CSCE 411, Spring 2012: Set 13

Page 22: CSCE 411 Design and Analysis of Algorithms

General Vertex Label Algorithm Generalization of Pair and Triple algorithms Assign a label to each vertex s.t.

labels are from a totally ordered, countably infinite set

new label for a sink depends only on old labels for the sink and its neighbors

sequence of labels taken on by a vertex increases without bound

Can prove termination and acyclicity preservation, and thus correctness.

22CSCE 411, Spring 2012: Set 13

Page 23: CSCE 411 Design and Analysis of Algorithms

Binary Link Labels Routing [Charron-Bost et al. SPAA 2009]

Alternate way to implement and generalize FR and PR

Instead of unbounded vertex labels, apply binary link labels to input DAG link directions are independent of labels (in contrast to

algorithms using vertex labels)

Algorithm for a sink: if at least one incident link is labeled 0, then reverse all

incident links labeled 0 and flip labels on all incident links if no incident link is labeled 0, then reverse all incident links

but change no labels

23CSCE 411, Spring 2012: Set 13

Page 24: CSCE 411 Design and Analysis of Algorithms

Binary Link Labels Example

24

0

1 2 3

0

0

1

1

CSCE 411, Spring 2012: Set 13

Page 25: CSCE 411 Design and Analysis of Algorithms

Binary Link Labels Example

25

0

1 2 30

0

1

1

CSCE 411, Spring 2012: Set 13

Page 26: CSCE 411 Design and Analysis of Algorithms

Binary Link Labels Example

26

0

1 2 3

0

10

1

CSCE 411, Spring 2012: Set 13

Page 27: CSCE 411 Design and Analysis of Algorithms

Why is BLL Correct? Termination can be proved very

similarly to termination for PR. What about acyclicity preservation?

Depends on initial labeling:

27

0

00 1

0

1

3

2

0

10 1

0

1

3

2

CSCE 411, Spring 2012: Set 13

Page 28: CSCE 411 Design and Analysis of Algorithms

Conditions on Initial Labeling All labels are the same

all 1’s => Full Reversal all 0’s => Partial Reversal

Every vertex has all incoming links labeled the same (“uniform” labeling)

Both of the above are special cases of a more general condition that is necessary and sufficient for preserving acyclicity

28CSCE 411, Spring 2012: Set 13

Page 29: CSCE 411 Design and Analysis of Algorithms

What About Complexity? Busch et al. (2003,2005) initiated study of

the performance of link reversal routing Work complexity of a vertex: number of

steps taken by the vertex Global work complexity: sum of work

complexity of all vertices Time complexity: number of iterations,

assuming all sinks take a step in each iteration (“greedy” execution)

29CSCE 411, Spring 2012: Set 13

Page 30: CSCE 411 Design and Analysis of Algorithms

Worst-Case Work Complexity Bounds [Busch et al.]

bad vertex: has no (directed) path to destination

Pair algorithm (Full Reversal): for every input, global work complexity is O(n2),

where n is number of initial bad vertices for every n, there exists an input with n bad

vertices with global work complexity Ω(n2) Triple algorithm (Partial Reversal): same

as Pair algorithm

30CSCE 411, Spring 2012: Set 13

Page 31: CSCE 411 Design and Analysis of Algorithms

Exact Work Complexity Bounds A more fine-grained question: Given any

input graph and any vertex in that graph, exactly how many steps does that vertex take?

Busch et al. answered this question for FR. Charron-Bost et al. answered this question

for BLL (as long as labeling satisfies Acyclicity Condition): includes FR and PR.

31CSCE 411, Spring 2012: Set 13

Page 32: CSCE 411 Design and Analysis of Algorithms

Definitions [Charron-Bost et al. SPAA 2009] Let X = <v1, v2, …, vk> be a chain in the labeled

input DAG (series of vertices s.t. either (vi,vi+1) or (vi+1,vi) is a link).

r: number of links that are labeled 1 and rightway ((vi,vi+1) is a link)

s: number of occurrences of vertices s.t. the two adjacent links are incoming and labeled 0

Res: 1 if last link in X is labeled 0 and rightway, else 0

32CSCE 411, Spring 2012: Set 13

Page 33: CSCE 411 Design and Analysis of Algorithms

Example of Definitions

For chain <D,7,6,5>: r = 1, s = 0, Res = 1For chain <D,1,2,3,4,5>: r = 2, s = 1, Res = 0

33

D0

0

1

1 0 1

7

1 2 3 8

6 5

4

1 01

CSCE 411, Spring 2012: Set 13

Page 34: CSCE 411 Design and Analysis of Algorithms

BLL Work Complexity Theorem: Consider any vertex v.

Let ωmin be the minimum, over all chains from D to v, of 2(r+s)+Res.Number of steps taken by v is (ωmin+1)/2 if initially v is a sink with all

incoming links labeled 0 ωmin/2 if initially v has all incoming links (if

any) labeled 1 ωmin otherwise

34CSCE 411, Spring 2012: Set 13

Page 35: CSCE 411 Design and Analysis of Algorithms

Work Complexity for FR

Corollary: For FR (all 1’s labeling), work complexity of vertex v is minimum, over all chains from D to v, of r, number of links in the chain that are rightway (directed away from D).

Worst-case graph for global work complexity:D 1 2 … n

vertex i has work complexity i global work complexity then is Θ(n2)

35CSCE 411, Spring 2012: Set 13

Page 36: CSCE 411 Design and Analysis of Algorithms

Work Complexity for PR Corollary: for PR (all 0’s labeling), work complexity

of vertex v is min, over all D-to-v chains, of s + Res if v is a sink or a

source min, over all D-to-v chains, of 2s + Res if v is neither a

sink nor a source Worst-case graph for global work complexity:

D 1 2 3 … n work complexity of vertex i is Θ(i) global work complexity is Θ(n2)

36CSCE 411, Spring 2012: Set 13

Page 37: CSCE 411 Design and Analysis of Algorithms

Comparing FR and PR Looking at worst-case global work complexity shows no

difference – both are quadratic in number of vertices Can use game theory to show some meaningful

differences (Charron-Bost et al. ALGOSENSORS 2009): global work complexity of FR can be larger than optimal (w.r.t. all

uniform labelings) by a factor of Θ(n) global work complexity of PR is never more than twice the optimal

Another advantage of PR over FR: In PR, if k links are removed, each vertex takes at most 2k steps In FR, if 1 link is removed, a vertex might have to take n-1 steps

37CSCE 411, Spring 2012: Set 13

Page 38: CSCE 411 Design and Analysis of Algorithms

Time Complexity Time complexity is number of iterations in

greedy execution Busch et al. observed that time complexity

cannot exceed global work complexity Thus O(n2) iterations for both FR and PR

Busch et al. also showed graphs on which FR and PR require Ω(n2) iterations

Charron-Bost et al. (2011) derived an exact formula for the last iteration in which any vertex takes a step in any graph for BLL…

38CSCE 411, Spring 2012: Set 13

Page 39: CSCE 411 Design and Analysis of Algorithms

FR Time Complexity Theorem: For every (bad) vertex v,

termination time of v is1 + max{len(X): X is chain ending at v with r = σv – 1}

where σv is the work complexity of v Worst-case graph for global time

complexity:

39

D

n-1n

n/2+1

n/221

n/2+2

n/2+3

vertex n/2 has work complexity n/2;consider chain that goes around the loopcounter-clockwise n/2-1 times starting andending at n/2: has r = n/2-1 and length Θ(n2)

CSCE 411, Spring 2012: Set 13

Page 40: CSCE 411 Design and Analysis of Algorithms

BLL Time Complexity What about other link labelings? Transform to FR! In more detail: for every labeled input

graph G (satisfying the Acyclicity Condition), construct another graph T(G) s.t. for every execution of BLL on G, there is a

“corresponding” execution of FR on T(G) time complexities of relevant vertices in the

corresponding executions are the same

40CSCE 411, Spring 2012: Set 13

Page 41: CSCE 411 Design and Analysis of Algorithms

Idea of Transformation If a vertex v is initially a sink with some links

labeled 0 and some labeled 1, or is not a sink with an incoming link labeled 0, then its incident links are partitioned into two sets: all links on one set reverse at odd-numbered steps by v all links in the other set reverse at even-numbered

steps by v Transformation replaces each such vertex with

two vertices, one corresponding to odd steps by v and the other to even steps, and inserts appropriate links

41CSCE 411, Spring 2012: Set 13

Page 42: CSCE 411 Design and Analysis of Algorithms

PR Time Complexity Theorem: For every (bad) vertex v, termination

time of v is 1 + max{len(X): X is a chain ending at v with s + Res = σv

– 1} if v is a sink or a source initially 1 + max{len(X): X is a chain ending at v with 2s + Res =

σv – 1} otherwise

Worst-case graph for global time complexity:D 1 2 3 … n/2 n/2+1 … n

Vertex n/2 has work complexity n/2. Consider chain that starts at n/2, ends at n/2, and goes back and forth between n/2 and n making (n-2)/4 round trips. 2s+Res for this chain is n/2-1, and length is Θ(n2).

42CSCE 411, Spring 2012: Set 13

Page 43: CSCE 411 Design and Analysis of Algorithms

FR vs. PR Again On chain on previous slide, PR has

quadratic time complexity. But FR on that chain has linear time

complexity in fact, FR has linear time complexity on any

tree On chain on previous slide, PR has

slightly better global work complexity than FR.

43CSCE 411, Spring 2012: Set 13

Page 44: CSCE 411 Design and Analysis of Algorithms

References Busch, Surapaneni and Tirthapura, “Analysis of Link Reversal Routing

Algorithms for Mobile Ad Hoc Networks,” SPAA 2003. Busch and Tirthapura, “Analysis of Link Reversal Routing Algorithms,”

SIAM JOC 2005. Charron-Bost, Fuegger, Welch and Widder, “Full Reversal Routing as a

Linear Dynamical System,” SIROCCO 2011. Charron-Bost, Fuegger, Welch and Widder, “Partial is Full,” SIROCCO

2011. Charron-Bost, Gaillard, Welch and Widder, “Routing Without Ordering,”

SPAA 2009. Charron-Bost, Welch and Widder, “Link Reversal: How to Play Better to

Work Less,” ALGOSENSORS 2009. Gafni and Bertsekas, “Distributed Algorithms for Generating Loop-Free

Routes in Networks with Frequently Changing Topology,” IEEE Trans. Comm. 1981.

Welch and Walter, “Link Reversal Algorithms,” Synthesis Lectures on Distributed Computing Theory #8, Morgan & Claypool Publishers, 2012.

44CSCE 411, Spring 2012: Set 13