11
Breadth-First Search and Shortest Path Kevin Schaffer Chapter 15.4 from “Distributed Algorithms” by Nancy A. Lynch

Breadth-First Search and Shortest Path Kevin Schaffer Chapter 15.4 from “Distributed Algorithms” by Nancy A. Lynch

Embed Size (px)

Citation preview

Page 1: Breadth-First Search and Shortest Path Kevin Schaffer Chapter 15.4 from “Distributed Algorithms” by Nancy A. Lynch

Breadth-First Search and Shortest Path

Kevin Schaffer

Chapter 15.4 from “Distributed Algorithms” by Nancy A. Lynch

Page 2: Breadth-First Search and Shortest Path Kevin Schaffer Chapter 15.4 from “Distributed Algorithms” by Nancy A. Lynch

Outline

• Breadth-First Search AsynchBFS LayeredBFS HybridBFS

• Shortest Path AsynchBellmanFord

Page 3: Breadth-First Search and Shortest Path Kevin Schaffer Chapter 15.4 from “Distributed Algorithms” by Nancy A. Lynch

AsynchBFS

• Similar to AsynchSpanningTree

• AsynchSpanningTree algorithm does not always generate a breadth-first spanning tree

• AsynchBFS detects incorrect parent assignments and corrects them

Page 4: Breadth-First Search and Shortest Path Kevin Schaffer Chapter 15.4 from “Distributed Algorithms” by Nancy A. Lynch

Safety and Liveness

• Safety For every process i i0, disti is the length of some path

p from i0 to i in G in which the predecessor of i is parenti.

For every message m in channel Ci,j, m is the length of some path p from i0 to i.

• Liveness For every pair of neighbors i and j, either distj disti +

1, or else either send(j)i or Ci,j contains the value disti.

Page 5: Breadth-First Search and Shortest Path Kevin Schaffer Chapter 15.4 from “Distributed Algorithms” by Nancy A. Lynch

Complexity of AsynchBFS

• Message complexity: O(n|E|) A node can receive at most n estimates, each of

which generates |E| messages

• Time complexity: O(diam n(l + d)) Length of the shortest path from i0 to any node

is diam and at most n messages are ever in any channel

Page 6: Breadth-First Search and Shortest Path Kevin Schaffer Chapter 15.4 from “Distributed Algorithms” by Nancy A. Lynch

Termination in AsynchBFS

• Problem with AsynchBFS: Processes do not know when to terminate

• Solution: Modify algorithm to perform a convergecast/broadcast at the end

• Not as straight-forward as AsynchBcastAck since processes may participate multiple times

Page 7: Breadth-First Search and Shortest Path Kevin Schaffer Chapter 15.4 from “Distributed Algorithms” by Nancy A. Lynch

LayeredBFS

• Constructs the BFS tree in phases• Each phase adds one layer to the tree; layer k

contains the nodes at depth k in the tree• Upon completion of phase k, all processes with

depth at most k know their parent and those at depth at most k – 1 know their children

• Acknowledgements let i0 know when each phase is complete

Page 8: Breadth-First Search and Shortest Path Kevin Schaffer Chapter 15.4 from “Distributed Algorithms” by Nancy A. Lynch

Complexity of LayeredBFS

• Message complexity: O(|E| + n diam) At most |E| search and acknowledgements At most diam + 1 phases At most n newphase/convergecast messages

• Time complexity: O(diam2(l + d)) Each phase takes diam(l + d)

Page 9: Breadth-First Search and Shortest Path Kevin Schaffer Chapter 15.4 from “Distributed Algorithms” by Nancy A. Lynch

HybridBFS

• HybridBFS performs an AsynchBFS multiple times, completing m layers during each phase

• If m = 1 then HybridBFS is similar to LayeredBFS and if m = diam then HybridBFS is similar to AsynchBFS

Page 10: Breadth-First Search and Shortest Path Kevin Schaffer Chapter 15.4 from “Distributed Algorithms” by Nancy A. Lynch

AsynchBellmanFord

• Generates a shortest path tree rooted at i0

• Similar to AsynchBFS but sends weighted distances

• Same problem with termination as AsynchBFS

Page 11: Breadth-First Search and Shortest Path Kevin Schaffer Chapter 15.4 from “Distributed Algorithms” by Nancy A. Lynch

Complexity of ABF

• Worst-case is exponential

• Message complexity: O(nn|E|) Maximum number of distinct simple paths

• Time complexity: O(nn + 1(l + d))