110 likes | 159 Views
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. AsynchBFS. Similar to AsynchSpanningTree
E N D
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
AsynchBFS • Similar to AsynchSpanningTree • AsynchSpanningTree algorithm does not always generate a breadth-first spanning tree • AsynchBFS detects incorrect parent assignments and corrects them
Safety and Liveness • Safety • For every process ii0, 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 distjdisti + 1, or else either send(j)i or Ci,j contains the value disti.
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(diamn(l + d)) • Length of the shortest path from i0 to any node is diam and at most n messages are ever in any channel
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
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
Complexity of LayeredBFS • Message complexity: O(|E| + ndiam) • 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)
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
AsynchBellmanFord • Generates a shortest path tree rooted at i0 • Similar to AsynchBFS but sends weighted distances • Same problem with termination as AsynchBFS
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))