Presentation is loading. Please wait.

Presentation is loading. Please wait.

Hwajung Lee. Why graph algorithms ? It is not a “graph theory” course! Many problems in networks can be modeled as graph problems. Note that -The topology.

Similar presentations


Presentation on theme: "Hwajung Lee. Why graph algorithms ? It is not a “graph theory” course! Many problems in networks can be modeled as graph problems. Note that -The topology."— Presentation transcript:

1 Hwajung Lee

2 Why graph algorithms ? It is not a “graph theory” course! Many problems in networks can be modeled as graph problems. Note that -The topology of a distributed system is a graph. - Routing table computation uses the shortest path algorithm - Efficient broadcasting uses a spanning tree - Maxflow algorithm determines the maximum flow between a pair of nodes in a graph.

3  Shortest path routing  Distance vector routing  Link state routing  Routing in sensor networks  Routing in peer-to-peer networks

4 Autonomous System AS0 AS1 AS2AS3 Intra-AS vs. Inter-AS routing Shortest Path First routing algorithm is the basis for OSPF Each AS is under a common administration

5 (borrowed from Cisco documentation http://www.cisco.com)

6 Most shortest path algorithms are adaptations of the classic Bellman-Ford algorithm. Computes shortest path if there are no cycle of negative weight. Let D(j) = shortest distance of j from initiator 0. Thus D(0) = 0 0 j k w(0,m), 0 (w(0,j)+w(j,k)), j The edge weights can represent latency or distance or some other appropriate parameter. Classical algorithms: Bellman-Ford, Dijkstra’s algorithm are found in most algorithm books. What is the difference between an ( ordinary ) graph algorithm and a distributed graph algorithm? m

7 Revisiting Bellman Ford : basic idea Consider a static topology Process 0 sends w(0,i),0 to neighbor i {program for process i} do message = (S,k)  S < D(i)  if parent ≠ k  parent := k fi; D(i) := S; send (D(i)+w(i,j),i) to each neighbor j ≠ parent;  message (S,k)  S ≥ D(i) --> skip od Computes the shortest distance to all nodes from an initiator node The parent pointers help the packets navigate to the initiator Current distance

8 Chandy & Misra’s algorithm : basic idea Consider a static topology Process 0 sends w(0,i),0 to neighbor i {for process i > 0} do message = (S,k)  S < D  if parent ≠ k  send ack to parent fi; parent := k; D := S; send (D + w(i,j), i) to each neighbor j ≠ parent; deficit := deficit + |N(i)| -1  message (S,k)  S ≥ D  send ack to sender  ack  deficit := deficit – 1 ÿ deficit = 0  parent  i  send ack to parent od 0 2 4 31 6 5 2 4 7 1 2 7 6 2 3 Combines shortest path computation with termination detection. Termination is detected when the initiator receives ack from each neighbor

9 An important issue is: how well do such algorithms perform when the topology changes? No real network is static! Let us examine distance vector routing that is adaptation of the shortest path algorithm

10 Distance Vector D for each node i contains N elements D[i,0], D[i,1], D[i,2] … Initialize these to  {Here, D[i,j] defines its distance from node i to node j.} - Each node j periodically sends its distance vector to its immediate neighbors. - Every neighbor i of j, after receiving the broadcasts from its neighbors, updates its distance vector as follows:  k≠ i: D[i,k] = min k (w[i,j] + D[j,k] ) Used in RIP, IGRP etc 1 1 1 1 D[j,k]=3 means j thinks k is 3 hops away

11 Node 1 thinks d(1,3) = 2 Node 2 thinks d(2,3) = d(1,3)+1 = 3 Node 1 thinks d(1,3) = d(2,3)+1 = 4 and so on. So it will take forever for the distances to stabilize. A partial remedy is the split horizon method that will prevent 1 from sending the advertisement about d(1,3) to 2 since its first hop is node 2 Observe what can happen when the link (2,3) fails.  k≠ i: D[i,k] = min k (w[i,j] + D[j,k] ) Suitable for smaller networks. Larger volume of data is disseminated, but to its immediate neighbors only Poor convergence property

12 Each node i periodically broadcasts the weights of all edges (i,j) incident on it (this is the link state ) to all its neighbors. The mechanism for dissemination is flooding. This helps each node eventually compute the topology of the network, and independently determine the shortest path to any destination node using some standard graph algorithm like Dijkstra’s. Smaller volume data disseminated over the entire network Used in OSPF

13  Each link state packet has a sequence number seq that determines the order in which the packets were generated.  When a node crashes, all packets stored in it are lost. After it is repaired, new packets start with seq = 0. So these new packets may be discarded in favor of the old packets!  Problem resolved using TTL

14 Theorem. The message complexity of Bellman-Ford algorithm is exponential. Proof outline. Consider a topology with an even number nodes 0 through n-1 (the unmarked edges have weight 0) 2020 2 k-12 2121 2k2k 0 n-5 4 2 n-3n-1 135 n-4n-2 Time the arrival of the signals so that D(n-1) reduces from (2 k+1 - 1) to 0 in steps of 1. Since k = (n-1)/2, it will need 2 (n+1)/2 -1 messages to reach the goal. So, the message complexity is exponential.

15 Conventional routing tables have a space complexity O(n). Can we route using a “smaller” routing table? Yes, by using interval routing. This is the motivation. conditionport number Destination > id 0 destination < id1 destination = id(local delivery) (Santoro and Khatib)

16  Determine the interva l to which the destination belongs.  For a set of N nodes 0.. N-1, the interval [p,q) between p and q ( p, q < N ) is defined as follows:  if p < q then [p,q) = p, p+1, p+2,.... q-2, q-1  if p ≥ q then [p,q) = p, p+1, p+2,..., N-1, N, 0, 1,..., q-2, q-1 [3,5) [5,1) [1,3)

17 N=11 Labeling is the crucial part

18 Label the root as 0. Do a pre-order traversal of the tree. Label successive nodes as 1, 2, 3 For each node, label the port towards a child by the node number of the child. Then label the port towards the parent by L(i) + T(i) + 1 mod N, where - L(i) is the label of the node i, - T(i) = # of nodes in the subtree under node i (excluding i), Question 1. Why does it work? Question 2. Does it work for non-tree topologies too? YES, but the construction is somewhat tricky.

19 Interval routing on a ring. The routes are not optimal. To make it optimal, label the ports of node i with i+1 mod 8 and i+4 mod 8.

20 Optimal interval routing scheme on a ring of six nodes

21 Works for static topologies. Difficult to adapt to changes in topologies. But there is some recent work on compact routing in dynamic topologies (Amos Korman, ICDCN 2009)

22 Easily adapts to changes in topology, and uses small routing tables, so it is scalable. Attractive for large networks, like P2P networks. a.a.a a.a.b a b When new nodes are added or existing nodes are deleted, changes are only local.

23 203310 1-02113 13-0200 130-112 1301-10 13010-1 130102 source destination Pastry P2P network

24 Chang-Robert’s algorithm {The root is known} {main idea} Uses probes and echoes, and keeps track of deficits C and D as in Dijkstra-Scholten’s termination detection algorithm first probe --> parent: = sender; C=1 forward probe to non-parent neighbors; update D echo --> decrement D probe and sender ≠ parent --> send echo C=1 and D=0 --> send echo to parent; C=0 For a graph G=(V,E), a spanning tree is a maximally connected subgraph T=(V,E’), E’  E,such that if one more edge is added, then the subgraph is no more a tree. Used for broadcasting in a network with O(N) complexity. Question: What if the root is not designated? Parent pointer

25 Many applications of exploring an unknown graph by a visitor (a token or mobile agent or a robot ). The goal of traversal is to visit every node at least once, and return to the starting point. - How efficiently can this be done? - What is the guarantee that all nodes will be visited? - What is the guarantee that the algorithm will terminate? Think about web-crawlers, exploration of social networks, planning of graph layouts for visualization or drawing etc. DFS (or BFS) traversal is well known, so we will not discuss about it

26 Rule 1. Send the token towards each neighbor exactly once. Rule 2. If rule 1 is not applicable, then send the token to the parent. Tarry’s algorithm is one of the oldest (1895) A possible route is: 0 1 2 5 3 1 4 6 2 6 4 1 3 5 2 1 0 Nodes and their parent pointers generate a spanning tree.

27 Given a weighted graph G = (V, E), generate a spanning tree T = (V, E’) E’  E such that the sum of the weights of all the edges is minimum. Applications Minimum cost vehicle routing On Euclidean plane, approximate solutions to the traveling salesman problem, Lease phone lines to connect the different offices with a minimum cost, Visualizing multidimensional data (how entities are related to each other) We are interested in distributed algorithms only The traveling salesman problem asks for the shortest route to visit a collection of cities and return to the starting point.

28

29 Review (1) Prim’s algorithm and (2) Kruskal’s algorithm. Theorem. If the weight of every edge is distinct, then the MST is unique.

30 Given a weighted graph G = (V, E), generate a spanning tree T = (V, E’) such that the sum of the weights of all the edges is minimum. Applications On Euclidean plane, approximate solutions to the traveling salesman problem, Lease phone lines to connect the different offices with a minimum cost, Visualizing multidimensional data (how entities are related to each other) We are interested in distributed algorithms only The traveling salesman problem asks for the shortest route to visit a collection of cities and return to the starting point.

31

32 Review (1) Prim’s algorithm and (2) Kruskal’s algorithm. Theorem. If the weight of every edge is distinct, then the MST is unique.

33  GHS is a distributed version of Prim’s algorithm.  Bottom-up approach. MST is recursively constructed by fragments joined by an edge of least cost. 3 7 5 Fragment

34 Challenge 1. How will the nodes in a given fragment identify the edge to be used to connect with a different fragment? A root node in each fragment is the root/coordinator

35 Challenge 2. How will a node in T1 determine if a given edge connects to a node of a different tree T2 or the same tree T1 ? Why will node 0 choose the edge e with weight 8, and not the edge with weight 4 ? Nodes in a fragment acquire the same name before augmentation.

36  Each fragment has a level. Initially each node is a fragment at level 0.  (MERGE) Two fragments at the same level L combine to form a fragment of level L+1  (ABSORB) A fragment at level L is absorbed by another fragment at level L’ (L < L’). The new fragment jhas a level L’. (Each fragment in level L has at least 2 L nodes)

37 To test if an edge is outgoing, each node sends a test message through a candidate edge. The receiving node may send accept or reject. Root broadcasts initiate in its own fragment, collects the report from other n odes about eligible edges using a convergecast, and determines the least weight outgoing edge. test reject accept

38 Let i send test to j Case 1. If name (i) = name (j ) then send reject Case 2. If name (i)≠name (j)  level (i)  level (j) then send accept Case 3. If name (i) ≠ name (j)  level (i) > level (j) then wait until level (j) = level (i) and then send accept/reject. WHY? (Note that levels can only increase). Q: Can fragments wait for ever and lead to a deadlock? test reject test

39 repeat 1 Test edges as outgoing or not 2 Determine lwoe - it becomes a tree edge 3 Send join (or respond to join) 4 Update level & name & identify new coordinator/root until done

40  Basic (initially all branches are basic)  Branch (all tree edges)  Rejected (not a tree edge) Branch and rejected are stable attributes

41 Merge The edge through which the join message is exchanged, changes its status to branch, and it becomes a tree edge. The new root broadcasts an ( initiate, L+1, name ) message to the nodes in its own fragment. Example of merge initiate

42 Absorb T’ sends a join message to T, and receives an initiate message. This indicates that the fragment at level L has been absorbed by the other fragment at level L ’. They collectively search for the lwoe. The edge through which the join message was sent, changes its status to branch. initiate Example of absorb

43 4 1 02 5 63 1 3 2 4 7 8 9 5 6

44 4 1 02 5 63 1 3 2 4 7 8 9 5 6 merge

45 4 1 02 5 63 1 2 4 7 8 9 5 6 absorb 3

46 4 1 02 5 63 1 2 4 7 8 9 5 6 3

47 At least two messages ( test + reject ) must pass through each rejected edge. The upper bound is 2|E| messages. At each of the log N levels, a node can receive at most (1) one initiate message and (2) one accept message (3) one join message (4) one test message not leading to a rejection, and (5) one changeroot message. So, the total number of messages has an upper bound of 2|E| + 5N logN


Download ppt "Hwajung Lee. Why graph algorithms ? It is not a “graph theory” course! Many problems in networks can be modeled as graph problems. Note that -The topology."

Similar presentations


Ads by Google