Presentation is loading. Please wait.

Presentation is loading. Please wait.

Tree Construction (BFS, DFS, MST) Chapter 5

Similar presentations


Presentation on theme: "Tree Construction (BFS, DFS, MST) Chapter 5"— Presentation transcript:

1 Tree Construction (BFS, DFS, MST) Chapter 5
Advanced Algorithms for Communication Networks and VLSI CAD - CS 6/75995 Presented By:Asrar Haque

2 Breadth-First Spanning Tree (BFS)
Definition: The breadth-first spanning tree, or the BFS tree, of G with respect to a given root ro is a spanning tree TB with the property that for every other vertex v, the path leading from the root to v is of minimum (unweighted) length possible. Basic Algorithm (Dijkstra’s Algorithm) BFS developed layer by layer from the root to downwards At any stage, build next layer by adding vertices that are not yet in the tree but are adjacent to some vertex that is in the tree

3 Layer-Synchronized BFS Construction (DIST_DIJK)
Vertex ro initiates and governs the algorithm A new layer is added in each phase After p phases the constructed tree is Tp rooted at ro; every vertex of Tp knows its parent, children (if exists) and depth

4 Layer-Synchronized BFS Construction (DIST_DIJK)

5 Example DIST_DIJK

6 Analysis (DIST_DIJK) Time
During phase p, broadcast and convergecast each take p time units Exploration stage take 2 additional time units Time (Phase p) = 2p + 2 Time(DIST_DIJK) = Messages Vp = set of vertices in layer p of T Ep = edges internal to Vp Ep, p+1 = edges connecting Vp to Vp+1 Message(DIST_DIJK)

7 Analysis (DIST_DIJK)

8 Update Based BFS (DIST_BF)
Initially, the root sets L(ro) ← 0, and others vertices v sets L(v) ← ∞ Root sends out message Layer(0) to all its neighbors Every vertex reacts to incoming messages as follows: Upon receiving a message Layer (d) from a neighbor w do: if d+1 < L(v), then do: a) parent (v) ← w; b) L(v) ← d+1 ; c) Send Layer (d+1) to all neighbors except w

9 Analysis (DIST_BF) Synchronous Model
Once a vertex, v, sets its L(v) to a value smaller than ∞ it is never changed v sends messages on its out going edges exactly once Time (DIST_BF) = O(Diam(G) Message (DIST_DIJK) = O(|E|) Asynchronous Model Lemma 5.3.2: For every d ≥1, after d time units from the start of execution every vertex v at distance d from the root has already received a Layer (d-1) message from some neighbor and, consequently set L(v) = d and chose a parent w with L(w) = d-1 The first value a vertex, v, sets L(v) is at most n-1 (longest possible simple path) v can change L(v) at most n-2 times and every time sends message over out going edges Message (DIST_BF) = O(n|E|)

10 Complexity Of BFS Construction Algorithms On G=(V,E) With Dia D

11 DFS Basic Algorithm The search pattern is based on continuing further into the graph Visits new vertex as long as possible Retracts from region only after exhausting it Search starts at some vertex ro When search reaches vertex v, if v has neighbors not yet visited one them Otherwise return to the vertex from which v was visited DFS Tree ro root The parent of vertex v, is the w from which v was visited first

12 Distributed DFS In reality sequential
Control carried via a “token” which traverses in depth first manner Time (DIST_DFS) = Message (DIST_DFS) = θ ( | E | ) Due to need to explore every edge lower bound for message Ω ( | E | ) Time complexity can be improved, Time (DIST_DFS) = O ( | n | )

13 Minimal Spanning Tree Problem Definition: G(V, E, ω) is a connected, undirected graph where V is the set of nodes and E is the set of edges and for each edge (u,v) E ω(u,v) is cost of edge (u,v). We need to find an acyclic subset that connects all the vertices and whose total weight ω(T)= is minimum

14 MST Fragment And The “Blue Rule”
Given a weighted grah G = (V, E, ω), a tree T in G is called MST Fragment of G if there exists an MST TM of G such that T is a sub-tree of TM Outgoing edge An edge e = (u, ω) of fragment T if only one end points belongs to T MWOE(T) The minimum weight outgoing edge of fragment T Blue Rule For a graph G = (V, E, ω) and fragment T in G, if e = MWOE(T) then T υ {e} is a fragment as well. “Pick a fragment T and add to it the MWOE(T)”

15 Distributed Prim’s Algorithm
Sequential Prim’s Algorithm Designate vertex ro as the initial fragment Repeatedly apply blue rule until reaching spanning tree Distributed Algorithm (DIST_PRIM) Asynchronous CONGEST model Vertex ro initiates and governs the algorithm A new edge is added in each phase After p phases the constructed tree is T rooted at ro; every vertex of Tp knows its parent, children (if exists) and which adjacent edges are internal and which are outgoing

16 Distributed Prim’s Algorithm

17 Distributed Prim’s Algorithm
Analysis DIST_PRIM Each phase p requires up to O (p) time and message Time (DIST_PRIM) = Message (DIST_PRIM) = O(n2)

18 Synchronous GHS Algorithm
Kruskal’s Algorithm Unlike Prim’s algorithm, multiple fragments exist in parallel Initially each vertex forms singleton fragments At each step, merge two fragments by selecting minimum weight outgoing edge from all fragments At the single fragment i.e. MST remains In sequential n-1 steps Distributed GHS Algorithm Synchronous CONGEST model At any given moment the vertices are partitioned into fragments F1, … Fk Fragment Fi is a rooted tree Each vertex in a Fi knows its parent, children, identifier of Fi

19 Phases of GHS Algorithm
Single Phase Each fragment F find e = MWOE(F) using convergecast as in DIST_PRIM Request_to_merge message send over edge e to chosen fragment F’ with id of fragment and root If other fragment also sends over the same edge then merges at the same point Otherwise the merged fragment will be composed of more than two fragments Each connected component of consists of a directed treewhose arc points are directed upwards towards the root, except that the root is not a single fragment , but rather a pair of fragments F1 and F2 poiting at each other

20 Phases of GHS Algorithm
Single Phase (Cont) Each connected component of consists of a directed treewhose arc points are directed upwards towards the root, except that the root is not a single fragment , but rather a pair of fragments F1 and F2 poiting at each other Choosing New root e = MWOE(F1) = MWOE(F2) and e =(v1, v2) If (v1 > v2) then v1 is the new root v1 sends NewFragment message informing all vertices its id Any vertex receiing NewFragment message updates fragment id and its parent, and neighbors Next Phase New fragment, F, finds its MWOE(F) and repeats the previous phase until one single fragment remains

21 Analysis of GHS Algorithm
Single Phase Each phase consist of a broadcast followed by conergecast involving not more than n vertices Time and message complexity for both broadcast followed by conergecast O (n) In fragment merge requires same comleity; additionally in final step each vertex let its neighbor know its new fragment if which costs θ(|E|) messages At most lg n phases Overall Complexity Time (GHS) = O(n lg n) Message (GHS) = O (|E| lg n) Lower Bound For clean network Message = Ω( |E| ) For arbitrary network Message = Ω( n lg n )

22 Using Red Rule In MST For G = (V, E, ω) MST solution gives weight ω*
G’ spanning subgraph of G, still contains spanning tree of ω* C is a cycle in G’ and e is the heaviest edge is C G’ \ {e} still contains spanning tree of weight ω* Red Rule “Pick an arbitrary cycle in the remaining graph and erase the heaviest edge in the cycle” d f g 10 1 11 14 1 10 11


Download ppt "Tree Construction (BFS, DFS, MST) Chapter 5"

Similar presentations


Ads by Google