Solution to exercise sheet
|
|
- Vernon Brooks
- 6 years ago
- Views:
Transcription
1 E cient Algorithms Summer term 2013 Institut für Theoretische Informatik Leibniz Universität Hannover Solution to exercise sheet Exercise 1: Prove Observation 1: Every forest is bipartite. Solution: Let F =(V,E) be a forest. Then F is acyclic. Divie V into its connecte components (i.e., trees) V = V 1 V k. In such a component there exists a unique path from one vertex to another. Now efine for each component V i an an arbitrary vertex u i œ V i a function i : V i V i æ N such that i (u i,v):= fi for the u i -v-path fi. Now we are able to efine the bipartition of V into A an B as follows: k A := {v œ V i i (u i,v) 2 0} fi {u i }, i=1 k B := {v œ V i i (u i,v) 2 1}. i=1 Let u, v œ A be some noes. Assume for contraiction that (u, v) œ E. As u, v œ V i for some 1 Æ i Æ k we have that i (u i,v) = i (u i,u) because u = v an V i is a tree. W.l.o.g. i (u i,v) 2 0 an then i (u i,u) 21. Hence u œ B an v œ A which is a contraiction. Exercise 2: Prove Observation 2: Let e be an ege of graph G. Then the following claims are equivalent. 1. e is a brige. 2. e is not part of any circle in G. 3. It hols Ÿ(G)+1=Ÿ(G e). Solution: We will prove the circular argument. Let G =(V,E) be a graph. 1 2: Let e be a brige. Assume that e = {u, v} is part of a circle in G. Consier V Õ V as the connecte component insie which fi is locate. Hence for all vertices w œ V Õ it hols that there are v-w-paths. Observe that in the Graph G e there is still a u-v-path through the remainer of the previous circle. Hence Ÿ(G) =Ÿ(G e) which is a contraiction. 2 3: Now e is not part of any circle in G. Let e = {u, v}. Hence there exists no u-v-path fi such that {u, v} /œ fi (because otherwise we woul have a circle with e). Hence G e contains no u-v-path wherefore Ÿ(G e) =Ÿ(G) : follows by efinition of a brige.
2 Exercise 3: Let G =(V,E) be an unirecte connecte graph an fi 1, fi 2 two longest simple paths in G. Prove that fi 1 fl fi 2 = ÿ, where fi 1 fl fi 2 := {v œ V v œ fi 1 an v œ fi 2 }. Solution: Given the unirecte connecte graph G =(V,E) an two longest simple paths fi 1 = p 1,...,p n an fi 2 = q 1,...,q n we observe that fi 1 = fi 2 hols. Assume for contraiction that there is no common vertex in fi 1 an fi 2. As G is connecte we can construct a path fi from the initial noe p 1 of fi 1 to the initial noe q 1 of fi 2. fi must leave fi 1 on some vertex x. Hence x ivies fi into two pieces. Lets say the longer part is fl 1 an is the path from either the first or the last vertex to x. fi also ivies fi 2 an efines a longer subpath in fi 2 which will be enote with fl 3 an moves from the first or the last noe of fi 2 to the vertex y where fi meets fi 2. The subpath in fi which is between x an y is enote with fl 2. As fi 1 an fi 2 have no common vertex (by assumption) fl 2 must consist of at least one ege. Through fl 1, fl 2, an fl 3 we efine a new path fi Õ. Through the previous choice of the longer subpaths it must hol fl 1 Ø fi 1 2 an fl 3 Ø fi 2 2. Combining with fl 2 Ø 1 we get for fi Õ : fi Õ Ø fi fi 2 2 = fi 1 +1= fi As fi 1, fi 2 are two longest paths in G we have a contraiction because fi Õ is longer. Hence there must be a common vertex.
3 E cient Algorithms Summer term 2013 Institut für Theoretische Informatik Leibniz Universität Hannover Solution to exercise sheet Exercise 1: Let G =(V,E) be a graph with Prove that G is connecte. (G)+ (G)+1Ø V. Solution: We prove this by confutation of the opposite: there is no unconnecte graph G such that (G)+ (G)+1= V. Hence there cannot be any unconnecte graph G with (G)+ (G)+1Ø V, because one woul have to a further eges. Thus for all graphs G with (G)+ (G)+1Ø V that they are connecte. Let G be an unconnecte graph. Then G can be partitione into the connecte components K 1,K 2,...,K n. Let enote with K max the connecte component with the maximum number of vertices. Only in this component a vertex egree of V Kmax 1 can be achieve. Similarly for the component K min consisting of the fewest vertices that the minimum vertex egree can be at most V Kmin 1. Now it hols that (G) = max vœv eg G v Æ V Kmax 1, (G) =min vœv eg G v Æ V Kmin 1, whence we get for the initial equation: (G)+ (G) + 1 = max vœv eg G v +min vœv eg G v +1Æ V Kmax 1+ V Kmin 1+1 = V Kmax + V Kmin 1 < V. For every unconnecte graph this equation oes not hol. Hence the opposite is true. Exercise 2: State an algorithm to etermine the connecte components of a given unirecte graph using BFS. Solution: We coul solve this exercise by the computation of strongly connecte components as in the following exercise after aing for each unirecte ege both irecte ones. However there is an algorithm that oes not make use of the SCCs which is fairly easy to fin:
4 Algorithm 1: Connecte-Components(G). Input 1 i Ω 0; : Unirecte graph G =(V,E) 2 while there is a vertex v œ V without a marking o 3 call BFS(G, v) anmarkallverticesu s.t. mark[u] =truewithi; 4 i Ω i +1; Exercise 3: State an algorithm to etermine the strongly an weakly connecte components of a given igraph. Solution: We will start by outputting the strongly connecte components (SCCs): Naturally we construct a epth-first-algorithm DFS from our BFS algorithm by using a stack instea of the queue. However we nee to exten the algorithm a little bit by introucing iscovery an finishing times. This is require to built an algorithm computing SCCs. So at first the DFS algorithm: Algorithm 2: Depth-first search DFS(G, s) Input :GraphG =(V,E). 1 Init route[v] with for every v œ V ; 2 stack S Ωÿ; 3 time Ω 0; 4 while there is an unmarke vertex s œ V o 5 S.push(s); 6 while S is not empty o 7 w Ω S.pop(); 8 time Ω time+1; 9 if w has a iscovery time then f(w) Ω time; // finishing time 10 else 11 (w) Ω time; // iscovery time 12 S.push(w); 13 forall the eges e =(w, v) œ E o 14 if not mark[v] then 15 mark[v] Ω true; 16 S.push(v); 17 route[v] Ω route[w]+1; Further we nee a last ingreient for the final algorithm: transposes of graphs. Let G = (V,E) be a irecte graph. Then G T = (V,E T is the transpose of G, where E T := {(u, v) (v, u) œ E}, i.e., we have reverse the irections. By ajacency-list representation it requires time O( V + E ) to create G T. Now the algorithm that computes the SCCs of a igraph is the following: Claim 1. The algorithm Strongly-Connecte-Components(G) is correct.
5 Algorithm 3: Strongly-Connecte-Components(G) Input : A igraph G =(V,E) 1 call DFS(G) to compute finishing times f(u) for each vertex u; 2 compute G T ; 3 call DFS(G T ), but now consier the eges in the forall-loop w.r.t. ecreasing orer of the finishing times of the vertices; 4 output the vertices of each tree in the epth-first forest forme in the previous line as a separate SCC. Proof of Claim 1. We prove the result by inuction on the number of epth-first trees foun in line 3 of the algorithm that the vertices of each tree form a SCC. The inuction hypothesis is that the first k trees prouce are SCCs. The basis for k =0is trivial. Inuction step k æ k +1: Let u be the root of the (k + 1)st tree an u be in the SCC C. Through the choice of roots it hols f(u) =f(c) >f(c Õ ) for any SCC C Õ other than C that has yet to be visite, where f(x) is max f(x) for x œ X. Now it is easy to show that all vertices of C are escenants of u in its epth-first tree. Further any eges in G T that leave C must be to SCCs that have alreay been visite. Hence no vertex in any SCC other than C will be a escenant of u uring the fs of G T. Hence, the vertices of the epth-first tree in G T roote at u form exactly one SCC. We say that the component graph G Õ for a given graph G is efine as follows. Let S 1,...,S k be the SCCs of G. Then replace each SCC S i by a fresh vertex s i an transfer the ege connections outsie of the SCC S i to s i. Now turn towars the weakly connecte components (WCCs). Here we make use of the following observation. A graph G is weakly connecte i its component graph G Õ is a path. By this one can easily use the previous algorithm for SCCs to compute the WCCs. Exercise 4: Explain why the DJP algorithm oes not work properly for negative weights. State an example where it fails. Solution: The problem is that the algorithm woul not ecie for a worse ege to get a much better ege in the next step. This is some kin of local minimum phenomenon. b 1 1 a 4-3 c So the shortest path from a to is over c but DJP woul choose the path over b.
6 E cient Algorithms Summer term 2013 Institut für Theoretische Informatik Leibniz Universität Hannover Solution to exercise sheet Exercise 1: Consier the following moification of the DJP algorithm to work with negative weights: Determine the smallest weight c œ Z in the weighte graph G = (V,E,w), i.e., the ege e s.t. w(e) =c. Then for all eges f œ E set w Õ (f) :=w(f) c. Then G Õ =(V,E,w Õ ) has no negative weights. Does the DJP algorithm work correctly on this type of graph? Prove your claim. Solution: Now we claim that DJP oes not work correctly on G Õ because this moification oes not maintain the shortest path property, i.e., if fi was a shortest path in G from s to t, thenfi is a shortest s-t-path in G Õ. The following counter-example proves this. a 1 7 b a 3 9 b c c In the left graph a, b, is the shortest path from a to. shorter. In the right graph a, is Exercise 2: Prove the upper-boun property: Let G =(V,E,w) be a weighte igraph an s œ V be a vertex. Then cost[v] Ø (s, v) for all v œ V an this invariant is maintaine over any sequence of relaxation steps on the eges of G. Moreover, once cost[v] achieves its lower boun (s, v), it never changes. So prove the invariant cost[v] Ø (s, v) for all v œ V by inuction over the number of relaxation steps. Solution: For the basis, cost[v] Ø (s, v) is certainly true after initialization, since cost[s] =0Ø (s, s) (note that (s, s) = Œ if s in on a negative-weight cycle an 0 otherwise) an cost[v] =Œ implies cost[v] Ø (s, v) for all v œ V {s}. For inuctive step, consier the relaxation of an ege (u, v). By the inuctive hypothesis, cost[x] Ø (s, x) for all x œ V prior to the relaxation. The only cost[ ] value that may change is cost[v]. If it changes, we have cost[v] =cost[u]+w(u, v) Ø (s, u)+w(u, v) Ø (s, v) (IH) (triangle property)
7 an so the invariant is maintaine. To see that the value of cost[v] never changes once cost[v] =(s, v), note that having achieve its lower boun, cost[v] cannot ecrease because we have just shown that cost[v] Ø (s, v), an it cannot increase because relaxation steps o not increase cost[ ] values. Exercise 3: Prove the convergence property: Let G =(V,E,w) be a weighte igraph an let (u, v) œ E. Then, immeiately after relaxing ege (u, v) in the if block we have cost[v] Æ cost[u]+w(u, v). Solution: If, just prior to relaxing ege (u, v), we have cost[v] > cost[u]+w(u, v), then cost[v] =cost[u] +w(u, v) afterwar. If, instea, cost[v] Æ cost[u] +w(u, v) just before the relaxation, then neither cost[u] nor cost[v] changes, an so cost[v] Æ cost[u]+w(u, v) afterwar. Exercise 4: Prove the path-relaxation property: If fi =(v 0,v 1,...,v k ) is a shortest path form s = v 0 to v k, an the eges of p are relaxe in the orer (v 0,v 1 ), (v 1,v 2 ),...,(v k 1,v k ), then cost[v k ]=(s, v k ). This property hols regarless of any other relaxation steps that occur, even if they are intermixe with relaxations of the eges of fi. Show by inuction that after the ith ege of fi is relaxe, we have cost[v i ]=(s, v i ). Solution: For the basis, i =0, an before any ege of fi have been relaxe, we have form the initialization that cost[v 0 ]=cost[s] =0=(s, s). By the upper-boun property, the value of cost[s] never changes after initialization. For the inuctive step, we assume that cost[v i 1 ] = (s, v i 1 ), an we examine the relaxation of ege (v i 1,v i ). By the convergence property, after this relaxation, we have cost[v i ]=(s, v i ), an this equality is maintaine at all times thereafter. Exercise 5: Prove the no-path property: Suppose that in a weighte, igraph G =(V,E,w), no path connects a source s œ V to a given vertex v œ V. Then we have cost[v] =(s, v) =Œ after initialization, an this equality is maintaine as an invariant over any sequence of relaxation steps on the eges of G. Solution: By the upper-boun property, we always have Œ = (s, v) Æ cost[v], an thus cost[v] =Œ = (s, v). Exercise 6: Prove the cost-array correctness: Let G =(V,E,w) be a weighte igraph an s œ V, an assume that G contains no negative cycles reachable from s. Then, after V 1 iterations of the for loop it hols cost[v] =(s, v) for all vertices v that are reachable from s. Solution: We prove the claim by appealing to the path-relaxation property. Consier any vertex v that is reachable from s, an let fi =(v 0,v 1,...,v k ) where v 0 = s an v k = v, be any acyclic shortest path from s to v. Path fi has at most V 1 eges,
8 an so k Æ V 1. Each of the V 1 iterations of the for loop relaxes all E eges. Among the eges relaxe in the ith iteration, for i =1, 2,...,k,is(v i 1,v i ). By the path-relaxation property, therefore, cost[v] =cost[v k ]=(s, v k )=(s, v). Exercise 7: Prove the preecessor-subgraph property: Let G =(V,E,w) be a weighte igraph, s œ V, an assume G contains no negativeweight cycles reachable from s. After the initialization of the algorithm execute any sequence of relaxation steps proucing cost[v] =(s, v) for all v œ V.Then,thepreecessor subgraph G route[ ] is as shortest-paths tree roote at s. Solution: We must check the three properties of Observation 6 for shortest-paths trees. For the first property, show that V route[ ] is the set of vertices reachable from s. By efinition, a shortest-path weight (s, v) is finite i v is reachable from s, hencethe vertices that are reachable from s are exactly those with finite cost[ ] values. But a vertex v œ V {s} has been assigne a finite value for cost[v] i route[v] =. Hence, the vertices in V route[ ] are exactly the reachable ones. Property two follows irectly from Lemma 1.8. It remains to prove the last property of shortest-paths trees: for each vertex v œ V route[ ] the unique simple path fi = v 0,...,v k with s = v 0 an v = v k in G route[ ] is a shortest path from s to v in G. For 1 Æ i Æ k we have both cost[v i ]=(s, v i ) an cost[v i ] Ø cost[v i 1 ]+ w(v i 1,v i ) from which we conclue w(v i 1,v i ) Æ (s, v i ) (s, v i 1 ). Summing the weights along fi yiels kÿ w(fi) = w(v i 1,v i ) i=1 kÿ! Æ (s, vi ) (s, v i 1 ) " i=1 = (s, v k ) (s, v 0 ) (sum telescopes) = (s, v k ) ((s, v 0 )=(s, s) = 0). Thus, w(fi) Æ (s, v k ).Since(s, v k ) is a lower boun on the weight of any path from s to v k, we conclue that w(fi) =(s, v k ),hencefi is a shortest path from s to v k = v.
9 E cient Algorithms Summer term 2013 Institut für Theoretische Informatik Leibniz Universität Hannover Solution to exercise sheet Exercise 1: Given a irecte graph G =(V,E) with V = {1, 2,...,n}, weefinethe transitive closure of G as the graph G ú =(V,E ú ),where E ú = {(i, j) œ V V there is a path from i to j in G}. Usually Boolean values require less storage than wors on current computers. Now construct an e cient algorithm to compute the transitive closure of a igraph which space requirement is less than the Floy-Warshall algorithm. Solution: The following algorithm uses only Boolean values rather than integer values, its space requirement is less than the Floy-Warshall algorithm s by a factor corresponing to the size of a wor of computer storage. Define t k (i, j) to be 1 if there exists a path in G from i to j with all intermeiate vertices in {1,...,k} an 0 otherwise. We construct the transitive closure G =(V,E ú ) by putting ege (i, j) into E ú i t n (i, j) =1: t 0 (i, j) = I 0, if i = j an (i, j) /œ E, 1, if i = j or (i, j) œ E, t k (i, j) =t k 1 (i, j)! t k 1 (i, k) t k 1 (k, j) ", if k Ø 1. Algorithm 1: Transitive-Closure(G =(V,E)) 1 n Ω V ; 2 for i Ω 1 to n o 3 for j Ω 1 to n o 4 if i = j or (i, j) œ E then t 0 (i, j) Ω 1; 5 else t 0 (i, j) Ω 0; 6 for k Ω 1 to n o 7 for i Ω 1 to n o 8 for j Ω 1 to n o 9 t k (i, j) Ω t k 1 (i, j)! t k 1 (i, k) t k 1 (k, j) " ; Exercise 2: Consier the following flow network with a given flow.
10 2/4 a 4/9 b 5/7 s 1/8 3/4 1/7 t 4/6 c 2/3 1/2 1. What is the flow across the cut ({s, c, }, {a, b, t})? What is the capacity of this cut? 2. Show the execution of For-Fulkerson on the flow network. Solution: 1. c({s, c, }, {a, b, t}) = = 20, an f({s, c, }, {a, b, t}) =2+3+( 1) = 6 2. Execution of FF (left the current flow network with the flow, right the resiual network): s 0/9 0/4 a 0/8 0/4 b 0/7 0/7 t s 9 a b 7 7 t 0/6 c 0/3 0/2 6 c 3 2 Consier the augmenting path p 1 = s, a, b, t. s 4/9 4/4 a 0/8 0/4 b 4/7 0/7 t s 4 a b t 0/6 c 0/3 0/2 6 c 3 2 Augmenting path p 2 = s, c,, b, t.
11 s 4/9 4/4 a 0/8 0/4 b 7/7 3/7 t s 4 a b t 3/6 c 3/3 0/2 3 3 c 3 2 Augmenting path p 3 = s, c, a, b,, t. s 6/9 4/4 a 0/8 2/4 b 7/7 1/7 t s 3 a b t 5/6 c 3/3 2/2 1 5 c 3 2 Now there oes not exist any other augmenting path an the algorithm terminates.
12 E cient Algorithms Summer term 2013 Institut für Theoretische Informatik Leibniz Universität Hannover Solution to exercise sheet Exercise 1: Six reporters Arne (A), Barbara (B), Christine (C), Daniela (D), Elvis (E) an Frank (F), are to be assigne to six news stories Politics (1), Crime (2), Financial (3), Foreign (4), Local (5) an Sport (6). The table shows possible allocations of reporters to news stories. For example, Christine can be assigne to any one of stories 1, 2 or A B C D E F 1. Show these possible allocations on a bipartite graph. 2. Use For-Fulkerson to compute a maximum matching. 3. Is there a perfect matching? Explain your answer. Solution: 1. A B C D E F A =5,B =1,C =2,E =6,F =4. 3. Looking at the bipartite graph, there is only one possible pair for each of A an D, both of which can only be paire to 5. Since 5 cannot be paire with two i erent vertices, a complete matching is not possible, since one of A an D will always remain unpaire.
13 Exercise 2: Can the following figure be tile by ominoes (a omino being 2 ajacent squares)? Give a tiling or a short proof that no tiling exists. Solution: Consier the bipartite graph G with a vertex for each square an two squares are ajacent if they share an ege. This graph is bipartite since the squares can be colore black an white in a checkerboar pattern. Any perfect tiling gives a perfect matching by simply selecting the eges corresponing to the ominoes selecte an vice versa. We claim that the configuration shown below is a maximum one an so no perfect tiling exists. We will prove that the matching M corresponing to the shown configuration is maximum by showing that there is no augmenting path as in the lecture. (Alternatively we coul use Hall s theorem.) Let A be the set of black squares an B the set of white squares. Orient the eges of G accoring to M, i.e., all the eges in M are oriente from B to A, an the eges not in M are oriente from A to B as in the oriente version. Let v be the only expose vertex of A an w be the only expose vertex of B, an consier L to be the set of vertices reachable from v (the enclose area in the oriente version). Since w is not in L we obtain that no augmenting path exists. We can also euce the fact that no perfect matching exists from Hall s theorem by observing that the 11 black vertices in L (the enclose region on the right) have only 10 (white) neighbors.
14 v w Exercise 3: Consier a bipartite graph G =(V,E) with bipartition (A, B) :V = AfiB. Assume that, for some vertex sets A 1 A an B 1 B, there exists a matching M A covering all vertices in A 1 an a matching M B covering all vertices in B 1. Prove that there always exists a matching covering all vertices in A 1 fi B 1. Solution: Let G =(V,E)=(AfiB,E), subsetsa 1 µ A, B 1 µ B an matchings M A,M B that cover A 1 an B 1, respectively. We construct a matching M that covers A 1 fi B 1. Clearly, the ege set M = M A fi M B covers A 1 fi B 1, but it is not necessarily a matching. We show how to elete eges from M to make it into a matching. We know M A M B is a union of isjoint cycles an alternating paths. The vertices with some incient ege from both M A \ M B an from M B \ M A are the only ones where M fails to be a matching. We show how to elete some eges from M A M B,soM is still a matching an no vertices are uncovere. We o so in each component of M A M B. Cycle: Since G is bipartite, the cycle has even length. Therefore, we can elete every other ege an the esire properties hol. Path of o number of eges: We can elete every other ege starting from the ege that is ajacent to the last ege of the path. The esire properties hol. Note that this is possible only because the path has o number of eges. Path of even number of eges: In this case, we can elete every other ege but one enpoint will be covere an the other uncovere. We nee to prove that both enpoints cannot be in A 1 fi B 1. Thus, we elete every other ege so the enpoint that is not in A 1 fi B 1 is uncovere. We o so by contraiction: assume both enpoints are in A 1 fib 1. As the path has an even number of eges, an G is bipartite, then both enpoints must belong to the same bipartition set (A or B). W.l.o.g. say they both belong to A, an thus also belong to A 1. Note that each vertex in A 1 has exactly one incient ege from M A ; thus the path we are analyzing (that is a connecte component of M A M B )must contain these two eges. However, this path is of even length, an is alternating, so the en-eges cannot be from the same matching M A ( ). This shows that our initial assumption is wrong, i.e., it must happen that both enpoints o not belong to A 1 fi B 1, as esire.
15
16 E cient Algorithms Summer term 2013 Institut für Theoretische Informatik Leibniz Universität Hannover Solution to exercise sheet Exercise 1: A bipartite graph G =(V, W, E) mit V = W is regular if all vertices v œ V fi W have the same egree eg v = 0. Show the following: Every regular bipartite graph has a perfect matching. Solution: Let G =(V,W,E) be a regular bipartite graph an the egree be k œ N. Counting the eges we get k V = k W. Hence it su ces to check Hall s conition because a matching which saturates V also saturates W an hence is a perfect matching. Let S V an let m S be the number of eges from S to (S). As G is regular with egree k it hols that m S = k S. These m S eges are incient to (S) an hence m S Æ k (S). Thus it hols k S Æ k (S), whence (S) Ø S is true for k>0 (which is true ue to the efinition of regular). As S has been chosen arbitrarily the result follows by Hall s theorem. Exercise 2: Let G =(U, V, E) be a bipartite graph, where U = {1,...,4} an V = {5,...,8}. The eges are efine as E = {{1, 5}, {1, 6}, {2, 5}, {3, 6}, {3, 8}, {4, 7}}. 1. Is there a perfect matching for G? Use Hall s theorem in your argumentation. 2. Construct a network through aing source an sink an compute a maximum matching with For-Fulkerson. Solution: 1. Yes, because for every A U it hols A Æ N(A). 2. The maximum matching we get is a perfect one: (1, 6), (2, 5), (3, 8), (4, 7). Exercise 3: Compute a maximum matching of G in the previous task with the technique of augmenting paths. Use a BFS to fin augmenting paths.
17 Solution: The following table shows the steps of BFS fining the augmenting paths an getting the matchings. augmenting path matching (1, 5) (1, 5) (2, 5), (5, 1), (1, 6) (2, 5), (1, 6) (3, 8) (2, 5), (1, 6), (3, 8) (7, 4) (2, 5), (1, 6), (3, 8), (7, 4) Exercise 4: Given graph G =(V, E) where V = {1,...,9} an E = {{1, 2}, {2, 3}, {3, 4}, {4, 5}, {5, 6}, {7, 8}, {8, 9}, {1, 7}, {2, 7}, {3, 9}, {4, 9}, {5, 8}, {6, 8}}. Compute a maximum matching of G with Emons algorithm. Solution:
18 E cient Algorithms Summer term 2013 Institut für Theoretische Informatik Leibniz Universität Hannover Solution to exercise sheet Exercise 1: Generalize Euler s formula to unconnecte plane graphs. Prove your claim. Solution: Euler s formula can be generalize as follows. Let G =(V,E) be a plane graph with c components. For each component Euler s formula n m + r =2hols. Now we nee to take care of the outer region. Every component shares this outer region. Hence we have c 1 regions less. It follows n+r (c 1) = m+2 or n+r c m = 1. Exercise 2: Prove the following: Let G be a triangle-free, connecte, plane graph with n(g) Ø 3. Then it hols m(g) Æ 2 n(g) 4. Solution: In a triangle-free graph which is not a forest any frontier of every region consists of at least 4 eges. Hence it hols 4 r(g) Æ 2 m(g). From Euler s formula we get n(g) m(g)+ 1 m(g) Ø 2 m(g) Æ 2 n(g) 4. 2 Exercise 3: Deuce from the previous task that K 3,3 is not planar. Solution: In particular every bipartite graph is triangle-free. As m(k 3,3 )=9> 8= 2 6 4=2 n(k 3,3 ) 4 we get K 3,3 is not planar. Exercise 4: Construct an algorithm which colors any arbitrary graph G with at most (G)+1colors. Solution: Algorithm 1: Algorithm to color an unirecte graph G with at most Input : graph G =(V,E), some fixe vertex enumeration v 1,...,v n œ V (G) 1 for i =1to n o 2 let c œ N be the smallest number such that f(v) = c for all {v i,v} œ E; 3 set f(v i ):=c. (G)+1 colors. Claim. Let G be some graph, then (G) Æ (G)+1. Proof of claim. Suppose the vertices of the graph have an arbitrary labeling 1,...,n. W.l.o.g. suppose
19 the algorithm processes vertices in the orer 1 to n. Further assume that the (G)+ 1 colors are C := {1,..., (G)+1}. Now the inuction hypothesis is that after i vertices have been processe, each of the vertices 1 to i is assigne a color in the set C such that for any ege {u, v} œ E an u, i Æ i the color f(u) = f(v), wheref : V æ C is the constructe coloring in the algorithm. Inuction basis. After 1 vertex has been processe, color 1 is use for the first vertex an we are one. X Inuction step. i æ i+1:vertexi+1 has at most (G) neighbors. Hence it has at most (G) neighbors that have alreay been assigne color. Thus there is at least one color in the set C that has not been use for any of i +1 s neighbors. The algorithm takes just the smallest remaining number in C to color vertex i +1. Hence the hypothesis still hols after assigning vertex i +1a color. Exercise 5: Construct two examples of graphs G with V (G) > 4 such that the algorithm from the previous task nees (G)+1colors an one where it requires less. Solution: The following graph will be colore with exactly 1= (G)+1color by the algorithm. v 1 v 2 v 3 v 4 v 4 The following graph will be colore with exactly 5= (G)+1colors by the algorithm. K 5 :
20 E cient Algorithms Summer term 2013 Institut für Theoretische Informatik Leibniz Universität Hannover Solution to exercise sheet Exercise 1: Given the problem Problem: OR n Input: n Boolean values x 0,...,x n 1 Task: Compute x n 1 i=0 x i Show that OR n œ CRCW(n, 1). Solution: We use a common CRCW-PRAM with n processors. If one of the values is Algorithm 1: OR n Ècommon CRCW-PRAMÍ 1 global S : Boolean, A: array[0,...,n 1] of Boolean; 2 local p, n: integer; 3 if p =0then S = false; 4 if A[p] then S = true; true, then the n-ary OR is true, otherwise it is false. For k Æ n trues k processors write k-times in parallel a true into the fiel S. This is allowe for CRC-PRAMs. Exercise 2: In the share memory of a PRAM a variable X is store. What is the fastest way to istribute the value of X into the local memory of each processor on a PRAM? Construct for each type of the possible PRAMs an algorithm with a runtime as e cient as possible. Solution: Algorithm 2: istribute ÈCR{C,W}W-PRAMÍ 1 global X : real; 2 local p, n: integer, x: real; 3 x Ω X; Hence istribute is in CR{C,W}W(n, 1). For the EREW-PRAM we will use a binary tree technique, i.e., at first X is copie to processor 0 then to 1, thencpu0 an 1 copy the value to 2 an 3 so on an so forth.
21 Algorithm 3: istribute ÈEREW-PRAMÍ 1 global X : real, temp: array[0,n 1] of real; // assume n =2 j for some j œ N 2 local p, n, i: integer, x: real; 3 if p =0then temp[0] = X; 4 for i =0to (log n) 1 o 5 if p<2 i then temp[p +2 i ] Ω temp[p]; 6 x Ω temp[p]; Here the runtime is O(log n). Exercise 3: Given the problem Problem: AND n Input: n Boolean values x 0,...,x n 1 Task: Compute w n 1 i=0 x i Show that AND n œ CRCW(m, n m ) for m Æ n. Solution: Iea: For m<nprocessors the first m bits are checke in parallel an one writes a false into the global fiel if a false was rea. Afterwars the array fiels with the numbers m +1 to 2 m are checke until all bits have been consiere. The runtime is O! Á n m Ë". For the case n = m the runtime is analogously to the OR-algorithm in Exercise 1 O(1). Algorithm 4: AND n Ècommon CRCW-PRAMÍ 1 global: A : array[0,...,n 1] of integer, S, n, m : integer; 2 local: p, i : integer; 3 i Ω 0,S Ω true; 4 while i<no 5 if A[p + i] is false then S Ω false; 6 i Ω i + m; Example. n = 10,N =4. ProzessorID i 1 i 2 i Arrayfel i k
22 E cient Algorithms Summer term 2013 Institut für Theoretische Informatik Leibniz Universität Hannover Solution to exercise sheet Exercise 1: Given an array A[0,...,n 1] of elements an an Boolean array B[0,...,n 1] s.t. B[n 1] = 1 hols. The array B inuces a ivision of A, i.e., every subarray of A ens on an inex j with B[j] =1. Now we are looking for the segmente prefix sums, i.e., the prefix sums of the by B inuce subarray A[i +1,...,j] of A such that the following hols 1. i = 1 or B[i] =1, 2. B[r] =0for i<r<j, 3. B[j] =1. Construct an algorithm which runs in O(log n) steps on an EREW-PRAM with O(n) processors. Note: You can use the principle of pointer jumping. Solution: Iea: Use principle of pointer jumping, where the B-array is use for the linking. Hence set I nil,ifb[i] =1 B[i] = i +1, otherwise Algorithm 1: segprefix ÈEREW-PRAMÍ 1 global A, s: array[0,...,n 1] of real, B : array[0,...,n 1] of integer; 2 local p, N, i: integer; // p an N initialize, N = n 3 S[p] :=A[p]; // copy array 4 if B[p] =1then B[p] :=nil; 5 else B[p] :=p +1; 6 while B[p] = nil o 7 S[B[p]] := S[B[p]] + S[p]; 8 B[p] :=B[B[p]]; Exercise 2: Every element of an n-array list L is colore either blue or re. Construct an e cient algorithm running on a CREW-PRAM which ivies L into two lists such that one consists of only re an the other of only blue elements.
23 Two global variables blist an rlist shall contain the initial pointers to these lists at the en of the computation. Solution: The following algorithm solves the task. During the process he buils two lists rnext, bnext which are at the en the lists of re/blue elements. The contain the inices of the separate lists. Initially rnext[p] = p + 1if A[p] = nil; an similarly for bnext. Algorithm 2: list-sort ÈCREW-PRAMÍ 1 global rnext, bnext: array[0,...,n 1] of integer; 2 color: array[0,...,n 1] of (blue, re); 3 blist, rlist: integer; 4 local p, N, i: integer; // p, N initialize n = N 5 for i := 0 to Âlog NÊ o 6 if rnext[p] = nil an color[rnext[p]] = re then rnext[p] := rnext[rnext[p]]; 7 if bnext[p] = nil an color[bnext[p]] = blue then bnext[p] := bnext[bnext[p]]; 8 if p =0then 9 if color[0] = re then blist := bnext[blist], rlist := 0; 10 else rlist = rnext[rlist], blist := 0;
24 E cient Algorithms Summer term 2013 Institut für Theoretische Informatik Leibniz Universität Hannover Solution to exercise sheet Another possibility for parallel computers is to consier the message passing moel where a global storage is not use. Formally one sees processors as vertices in a unirecte graph an the eges are biirectional communication channels. Still, the processors work synchronously with the following exceptions: After execution of the operation sen(object, ProcessorI) the sener-processor can immeiately continue, receive(variable, ProcessorI) the receiver-processor waits until he gets the esire object. The unerlying net-topology has three important attributes: Diameter Maximum istance of two vertices. Degree Maximum egree of a vertex. Bisection with Divie the set of vertices into two almost equal halves. The bisection with is then the number of eges connecting both sets. Exercise 1: A processor ring is an array consisting of n processors which are linearly linke an the last processor in the array is linke to the first: p 0 p 1 p n 1 1. What are the attribute values of this topology? 2. Given an n n matrix A an an n-vector b one shall compute A b. Construct an algorithm on a processor ring with N Æ n processors running in ( n2 N ) time with communication time (N n). Solution: 1. Diameter Degree 2 Í N 2 Î Bisection with 2
25 2. W.l.o.g. let N be a ivisor of n an let r = n N. Now the iea is to ivie A into N sub matrices of size n r, Q R A = c a A 0 A 1 A N 1 b r r r r an b such that b i is a tuple of length r. Then it hols that A b = A 0 b 0 + A 1 b A N 1 b N 1. Algorithm 1: matmultvec ÈRingÍ 1 N, p: integer; // initialize 0, Æ p<n 2 B : array[1,...,n][1,...,r] of real; // Submatrix A p 3 w : array[1,...,r] of real; // Subvector b p 4 y, z: array[1,...,n] of real; 5 Compute locally z = A p b p ; 6 if p =0then y := 0; 7 else receive(y, p 1); 8 y := y + z; 9 sen(y, (p + 1) mo N); 10 if p =0then receive(y, N 1); Observations: The processors compute in parallel the proucts A p b p. Then all processors with is 1 to N 1 wait for the ata of their left neighbor. P 0 sets y to A 0 b 0 an sens the result to the right neighbor etc. P 0 then waits for the full sum. The computation time is (r n) = ( n2 N ). The communication time is (N n) because P 0 has to wait until all values are summe up. Exercise 2: A processor gri consists of N = m 2 processors which are arrange as an m m matrix an are connecte as follows:
26 p 0,0 p 0,1 p 0,m 1 p 1,0 p 1,1 p 1,mn 1 :. :. :. p m 1,0 p m 1,1 p m 1,m 1 1. What are the attribute values of this topology? 2. Construct an algorithm computing the prouct of two n n matrices in (n) steps. Solution: 1. Diameter 2(m 1) Degree 4 Bisection with m 2. Iea: The rows of A will be entere in inverte orer from left the columns of B from top into the gri. Every processor P ij gets in every step two inputs A[i, ] an B[,j], sums the prouct an sens A[i, ] to the right an B[,j] to bottom. B[0,3] B[0,2] B[0,1] B[0,0] :. B[1,2] B[1,1] B[1,0] :. B[2,1] B[2,0] :. B[3,0] B A[0,3] A[0,2] A[0,1] A[0,0] P 0,0 P 0,1 P 0,2 P 0,3 A[1,2] A[1,1] A[1,0] P 1,0 P 1,1 P 1,2 P 1,3 A[2,1] A[2,0] P 2,0 P 2,1 P 2,2 P 2,3 A[3,0] A P 3,0 P 3,1 P 3,2 P 3,3
27 Algorithm 2: matmul ÈGriÍ 1 n, i,j: integer; // initialize, (i, j) = processor i 2 A, B, C : real; // A contains A[i, k] an B contains B[k, j] 3 : integer; 4 C := A B; 5 for := 1 to n 1 o 6 sen(a, (i, (j + 1) mo n)); 7 sen(b,((i + 1) mo n, j)); 8 receive(a, (i, (j 1) mo n)); 9 receive(b,((i 1) mo n, j)); 10 C := C + A B; Observations: After (n) steps processor P ij has compute the correct value of C[i, j]. Systolic algorithm. The values flow in common moe through the gri. After (n) steps matrix C can be rea. Speeup of magnitue n 2 hence optimal speeup. The coe cient of A an B can be ivie onto the processors of a torus an use the same algorithm.
28 E cient Algorithms Summer term 2013 Institut für Theoretische Informatik Leibniz Universität Hannover Solution to exercise sheet Exercise 1: A hypercube of imension consists of 2 processors which are numbere by the -ary ual-representation of processor is. Two processors are connecte through a communication channel if their is have a hamming istance of 1 (i.e., their ualrepresentation i ers in exactly one bit). The structure of a hypercube is recursively efine: The hypercube of imension +1choose two hypercubes H 1,H 2 of imension. The is of H 1 are precee with a 1 an the is of H 2 with a 0. Then connect the corresponing vertices with an ege = = =2 1. What are the attribute values (efine on the last exercise sheet) of this topology? 2. How many vertices an how many eges are in a hypercube of imension? 3. Given a hypercube of imension. What is the shortest path to pass a message from vertex u to the vertex v? 4. Construct an algorithm which computes the sum of the elements of a given array A of length n =2 on a hypercube of imension running in O(log n) steps. 5. Construct an algorithm which istributes a value store in p 0 through the complete net in O() steps in a hypercube of imension. Solution: 1. Diameter Degree
29 Bisection with Vertices: 2, Eges: The shortest path between two i erent vertices u, v is 1 Æ u ü v 1 Æ. 4. We assume that A[i] is store in the local variable B of processor i. The sum q ni=0 A[i] is store at the en of the computation in P 0. Algorithm 1: sum ÈHypercubeÍ 1 N,p: integer; // initialize 0 Æ p<2 2 B,C : real; // B contains A[p] 3 m, : integer; 4 := log N; // Assumption: N = s = n 5 for m := 1 own to 0 o 6 if 2 m Æ p<2 m+1 then sen(b,p&(2 m 1)); // bitwise an 7 if p<2 m then 8 receive(c, p 2 m ); // bitwise or 9 B := B + C; In the first if-conition the processors with the is ( 0 01?? ) are chosen. m They sen to the processors ( 0 0?? ) m in the secon if-conition the processors with the is ( 0 00?? ) are cho- m sen an they receive from the processors ( 0 01?? ) m The algorithm runs in O(log n) steps.
30 5. Here we state an algorithm which istributes a variable x store in p 0 through the complete net. At first, p 0 sens x to p 1, then both to p 2 an p 3, an so on an Algorithm 2: istribute ÈHypercubeÍ 1 N,p: integer; // initialize, 0 Æ p<n=2 2 x: real; 3, i: integer; 4 := log N; 5 for i =0to 1 o 6 if p<2 i then // p =(0 0?? ) i 7 sen(x, p 2 i ); 8 if 2 i Æ p<2 i+1 then // p =(0 01?? ) i 9 receive(x, p&(2 i 1)); so forth. The algorithm runs in O(log n).
Pairwise alignment using shortest path algorithms, Gunnar Klau, November 29, 2005, 11:
airwise alignment using shortest path algorithms, Gunnar Klau, November 9,, : 3 3 airwise alignment using shortest path algorithms e will iscuss: it graph Dijkstra s algorithm algorithm (GDU) 3. References
More informationAdditional Divide and Conquer Algorithms. Skipping from chapter 4: Quicksort Binary Search Binary Tree Traversal Matrix Multiplication
Aitional Divie an Conquer Algorithms Skipping from chapter 4: Quicksort Binary Search Binary Tree Traversal Matrix Multiplication Divie an Conquer Closest Pair Let s revisit the closest pair problem. Last
More informationBIJECTIONS FOR PLANAR MAPS WITH BOUNDARIES
BIJECTIONS FOR PLANAR MAPS WITH BOUNDARIES OLIVIER BERNARDI AND ÉRIC FUSY Abstract. We present bijections for planar maps with bounaries. In particular, we obtain bijections for triangulations an quarangulations
More informationGeneralized Edge Coloring for Channel Assignment in Wireless Networks
TR-IIS-05-021 Generalize Ege Coloring for Channel Assignment in Wireless Networks Chun-Chen Hsu, Pangfeng Liu, Da-Wei Wang, Jan-Jan Wu December 2005 Technical Report No. TR-IIS-05-021 http://www.iis.sinica.eu.tw/lib/techreport/tr2005/tr05.html
More informationCS521 \ Notes for the Final Exam
CS521 \ Notes for final exam 1 Ariel Stolerman Asymptotic Notations: CS521 \ Notes for the Final Exam Notation Definition Limit Big-O ( ) Small-o ( ) Big- ( ) Small- ( ) Big- ( ) Notes: ( ) ( ) ( ) ( )
More informationGeneralized Edge Coloring for Channel Assignment in Wireless Networks
Generalize Ege Coloring for Channel Assignment in Wireless Networks Chun-Chen Hsu Institute of Information Science Acaemia Sinica Taipei, Taiwan Da-wei Wang Jan-Jan Wu Institute of Information Science
More information2-connected graphs with small 2-connected dominating sets
2-connecte graphs with small 2-connecte ominating sets Yair Caro, Raphael Yuster 1 Department of Mathematics, University of Haifa at Oranim, Tivon 36006, Israel Abstract Let G be a 2-connecte graph. A
More informationLecture 3: Graphs and flows
Chapter 3 Lecture 3: Graphs and flows Graphs: a useful combinatorial structure. Definitions: graph, directed and undirected graph, edge as ordered pair, path, cycle, connected graph, strongly connected
More informationCS473-Algorithms I. Lecture 13-A. Graphs. Cevdet Aykanat - Bilkent University Computer Engineering Department
CS473-Algorithms I Lecture 3-A Graphs Graphs A directed graph (or digraph) G is a pair (V, E), where V is a finite set, and E is a binary relation on V The set V: Vertex set of G The set E: Edge set of
More informationCS 341: Algorithms. Douglas R. Stinson. David R. Cheriton School of Computer Science University of Waterloo. February 26, 2019
CS 341: Algorithms Douglas R. Stinson David R. Cheriton School of Computer Science University of Waterloo February 26, 2019 D.R. Stinson (SCS) CS 341 February 26, 2019 1 / 296 1 Course Information 2 Introduction
More informationSingle Source Shortest Path
Single Source Shortest Path A directed graph G = (V, E) and a pair of nodes s, d is given. The edges have a real-valued weight W i. This time we are looking for the weight and the shortest path from s
More informationSolutions to Tutorial 1 (Week 8)
The University of Syney School of Mathematics an Statistics Solutions to Tutorial 1 (Week 8) MATH2069/2969: Discrete Mathematics an Graph Theory Semester 1, 2018 1. In each part, etermine whether the two
More information1 Shortest Path Problems
CS268: Geometric Algorithms Hanout #7 Design an Analysis Original Hanout #18 Stanfor University Tuesay, 25 February 1992 Original Lecture #8: 4 February 1992 Topics: Shortest Path Problems Scribe: Jim
More informationMC 302 GRAPH THEORY 10/1/13 Solutions to HW #2 50 points + 6 XC points
MC 0 GRAPH THEORY 0// Solutions to HW # 0 points + XC points ) [CH] p.,..7. This problem introduces an important class of graphs called the hypercubes or k-cubes, Q, Q, Q, etc. I suggest that before you
More informationCS2 Algorithms and Data Structures Note 10. Depth-First Search and Topological Sorting
CS2 Algorithms and Data Structures Note 10 Depth-First Search and Topological Sorting In this lecture, we will analyse the running time of DFS and discuss a few applications. 10.1 A recursive implementation
More informationGraduate Algorithms CS F-15 Graphs, BFS, & DFS
Grauate Algorithms CS67-206F-5 Graphs, BFS, & DFS Davi Galles Department o Computer Science University o San Francisco 5-0: Graphs A graph consists o: A set o noes or vertices (terms are interchangeable)
More information22 Elementary Graph Algorithms. There are two standard ways to represent a
VI Graph Algorithms Elementary Graph Algorithms Minimum Spanning Trees Single-Source Shortest Paths All-Pairs Shortest Paths 22 Elementary Graph Algorithms There are two standard ways to represent a graph
More informationShortest Path Problem
Shortest Path Problem CLRS Chapters 24.1 3, 24.5, 25.2 Shortest path problem Shortest path problem (and variants) Properties of shortest paths Algorithmic framework Bellman-Ford algorithm Shortest paths
More informationJessica Su (some parts copied from CLRS / last quarter s notes)
1 Max flow Consider a directed graph G with positive edge weights c that define the capacity of each edge. We can identify two special nodes in G: the source node s and the sink node t. We want to find
More informationGraph Representation
Graph Representation Adjacency list representation of G = (V, E) An array of V lists, one for each vertex in V Each list Adj[u] contains all the vertices v such that there is an edge between u and v Adj[u]
More informationThe Reconstruction of Graphs. Dhananjay P. Mehendale Sir Parashurambhau College, Tilak Road, Pune , India. Abstract
The Reconstruction of Graphs Dhananay P. Mehenale Sir Parashurambhau College, Tila Roa, Pune-4030, Inia. Abstract In this paper we iscuss reconstruction problems for graphs. We evelop some new ieas lie
More informationarxiv: v1 [math.co] 15 Dec 2017
Rectilinear Crossings in Complete Balance -Partite -Uniform Hypergraphs Rahul Gangopahyay Saswata Shannigrahi arxiv:171.05539v1 [math.co] 15 Dec 017 December 18, 017 Abstract In this paper, we stuy the
More informationComputer Organization
Computer Organization Douglas Comer Computer Science Department Purue University 250 N. University Street West Lafayette, IN 47907-2066 http://www.cs.purue.eu/people/comer Copyright 2006. All rights reserve.
More informationLECTURES 3 and 4: Flows and Matchings
LECTURES 3 and 4: Flows and Matchings 1 Max Flow MAX FLOW (SP). Instance: Directed graph N = (V,A), two nodes s,t V, and capacities on the arcs c : A R +. A flow is a set of numbers on the arcs such that
More informationGraph Algorithms. Andreas Klappenecker. [based on slides by Prof. Welch]
Graph Algorithms Andreas Klappenecker [based on slides by Prof. Welch] 1 Directed Graphs Let V be a finite set and E a binary relation on V, that is, E VxV. Then the pair G=(V,E) is called a directed graph.
More informationDFS & STRONGLY CONNECTED COMPONENTS
DFS & STRONGLY CONNECTED COMPONENTS CS 4407 Search Tree Breadth-First Search (BFS) Depth-First Search (DFS) Depth-First Search (DFS) u d[u]: when u is discovered f[u]: when searching adj of u is finished
More informationW4231: Analysis of Algorithms
W4231: Analysis of Algorithms 10/21/1999 Definitions for graphs Breadth First Search and Depth First Search Topological Sort. Graphs AgraphG is given by a set of vertices V and a set of edges E. Normally
More informationVariable Independence and Resolution Paths for Quantified Boolean Formulas
Variable Inepenence an Resolution Paths for Quantifie Boolean Formulas Allen Van Geler http://www.cse.ucsc.eu/ avg University of California, Santa Cruz Abstract. Variable inepenence in quantifie boolean
More informationThese are not polished as solutions, but ought to give a correct idea of solutions that work. Note that most problems have multiple good solutions.
CSE 591 HW Sketch Sample Solutions These are not polished as solutions, but ought to give a correct idea of solutions that work. Note that most problems have multiple good solutions. Problem 1 (a) Any
More information6.854J / J Advanced Algorithms Fall 2008
MIT OpenCourseWare http://ocw.mit.eu 6.854J / 18.415J Avance Algorithms Fall 2008 For inormation about citing these materials or our Terms o Use, visit: http://ocw.mit.eu/terms. 18.415/6.854 Avance Algorithms
More informationIntensive Hypercube Communication: Prearranged Communication in Link-Bound Machines 1 2
This paper appears in J. of Parallel an Distribute Computing 10 (1990), pp. 167 181. Intensive Hypercube Communication: Prearrange Communication in Link-Boun Machines 1 2 Quentin F. Stout an Bruce Wagar
More informationGraph Representations and Traversal
COMPSCI 330: Design and Analysis of Algorithms 02/08/2017-02/20/2017 Graph Representations and Traversal Lecturer: Debmalya Panigrahi Scribe: Tianqi Song, Fred Zhang, Tianyu Wang 1 Overview This lecture
More informationDr. Amotz Bar-Noy s Compendium of Algorithms Problems. Problems, Hints, and Solutions
Dr. Amotz Bar-Noy s Compendium of Algorithms Problems Problems, Hints, and Solutions Chapter 1 Searching and Sorting Problems 1 1.1 Array with One Missing 1.1.1 Problem Let A = A[1],..., A[n] be an array
More informationCHAPTER 23: ELEMENTARY GRAPH ALGORITHMS Representations of graphs
CHAPTER 23: ELEMENTARY GRAPH ALGORITHMS This chapter presents methods for representing a graph and for searching a graph. Searching a graph means systematically following the edges of the graph so as to
More information22 Elementary Graph Algorithms. There are two standard ways to represent a
VI Graph Algorithms Elementary Graph Algorithms Minimum Spanning Trees Single-Source Shortest Paths All-Pairs Shortest Paths 22 Elementary Graph Algorithms There are two standard ways to represent a graph
More informationFrequent Pattern Mining. Frequent Item Set Mining. Overview. Frequent Item Set Mining: Motivation. Frequent Pattern Mining comprises
verview Frequent Pattern Mining comprises Frequent Pattern Mining hristian Borgelt School of omputer Science University of Konstanz Universitätsstraße, Konstanz, Germany christian.borgelt@uni-konstanz.e
More informationOptimal Oblivious Path Selection on the Mesh
Optimal Oblivious Path Selection on the Mesh Costas Busch Malik Magon-Ismail Jing Xi Department of Computer Science Rensselaer Polytechnic Institute Troy, NY 280, USA {buschc,magon,xij2}@cs.rpi.eu Abstract
More informationCOL351: Analysis and Design of Algorithms (CSE, IITD, Semester-I ) Name: Entry number:
Name: Entry number: There are 6 questions for a total of 75 points. 1. Consider functions f(n) = 10n2 n + 3 n and g(n) = n3 n. Answer the following: (a) ( 1 / 2 point) State true or false: f(n) is O(g(n)).
More informationDefinition For vertices u, v V (G), the distance from u to v, denoted d(u, v), in G is the length of a shortest u, v-path. 1
Graph fundamentals Bipartite graph characterization Lemma. If a graph contains an odd closed walk, then it contains an odd cycle. Proof strategy: Consider a shortest closed odd walk W. If W is not a cycle,
More informationPart VI Graph algorithms. Chapter 22 Elementary Graph Algorithms Chapter 23 Minimum Spanning Trees Chapter 24 Single-source Shortest Paths
Part VI Graph algorithms Chapter 22 Elementary Graph Algorithms Chapter 23 Minimum Spanning Trees Chapter 24 Single-source Shortest Paths 1 Chapter 22 Elementary Graph Algorithms Representations of graphs
More informationThroughput Characterization of Node-based Scheduling in Multihop Wireless Networks: A Novel Application of the Gallai-Edmonds Structure Theorem
Throughput Characterization of Noe-base Scheuling in Multihop Wireless Networks: A Novel Application of the Gallai-Emons Structure Theorem Bo Ji an Yu Sang Dept. of Computer an Information Sciences Temple
More informationDivide-and-Conquer Algorithms
Supplment to A Practical Guie to Data Structures an Algorithms Using Java Divie-an-Conquer Algorithms Sally A Golman an Kenneth J Golman Hanout Divie-an-conquer algorithms use the following three phases:
More information1 Surprises in high dimensions
1 Surprises in high imensions Our intuition about space is base on two an three imensions an can often be misleaing in high imensions. It is instructive to analyze the shape an properties of some basic
More informationγ(ɛ) (a, b) (a, d) (d, a) (a, b) (c, d) (d, d) (e, e) (e, a) (e, e) (a) Draw a picture of G.
MAD 3105 Spring 2006 Solutions for Review for Test 2 1. Define a graph G with V (G) = {a, b, c, d, e}, E(G) = {r, s, t, u, v, w, x, y, z} and γ, the function defining the edges, is given by the table ɛ
More informationSkyline Community Search in Multi-valued Networks
Syline Community Search in Multi-value Networs Rong-Hua Li Beijing Institute of Technology Beijing, China lironghuascut@gmail.com Jeffrey Xu Yu Chinese University of Hong Kong Hong Kong, China yu@se.cuh.eu.h
More informationLecture 10,11: General Matching Polytope, Maximum Flow. 1 Perfect Matching and Matching Polytope on General Graphs
CMPUT 675: Topics in Algorithms and Combinatorial Optimization (Fall 2009) Lecture 10,11: General Matching Polytope, Maximum Flow Lecturer: Mohammad R Salavatipour Date: Oct 6 and 8, 2009 Scriber: Mohammad
More information1. (a) O(log n) algorithm for finding the logical AND of n bits with n processors
1. (a) O(log n) algorithm for finding the logical AND of n bits with n processors on an EREW PRAM: See solution for the next problem. Omit the step where each processor sequentially computes the AND of
More informationarxiv: v2 [math.co] 5 Jun 2018
Some useful lemmas on the ege Szege inex arxiv:1805.06578v [math.co] 5 Jun 018 Shengjie He 1 1. Department of Mathematics, Beijing Jiaotong University, Beijing, 100044, China Abstract The ege Szege inex
More informationProving Vizing s Theorem with Rodin
Proving Vizing s Theorem with Roin Joachim Breitner March 25, 2011 Proofs for Vizing s Theorem t to be unwiely unless presente in form a constructive algorithm with a proof of its correctness an termination.
More informationCS350 - Exam 4 (100 Points)
Fall 0 Name CS0 - Exam (00 Points).(0 points) Re-Black Trees For the Re-Black tree below, inicate where insert() woul initially occur before rebalancing/recoloring. Sketch the tree at ALL intermeiate steps
More informationExercise set 2 Solutions
Exercise set 2 Solutions Let H and H be the two components of T e and let F E(T ) consist of the edges of T with one endpoint in V (H), the other in V (H ) Since T is connected, F Furthermore, since T
More informationLecture 1 September 4, 2013
CS 84r: Incentives an Information in Networks Fall 013 Prof. Yaron Singer Lecture 1 September 4, 013 Scribe: Bo Waggoner 1 Overview In this course we will try to evelop a mathematical unerstaning for the
More informationChapter 22. Elementary Graph Algorithms
Graph Algorithms - Spring 2011 Set 7. Lecturer: Huilan Chang Reference: (1) Cormen, Leiserson, Rivest, and Stein, Introduction to Algorithms, 2nd Edition, The MIT Press. (2) Lecture notes from C. Y. Chen
More informationAlgorithm Design and Analysis
Algorithm Design and Analysis LECTURE 7 Greedy Graph Algorithms Topological sort Shortest paths Adam Smith The (Algorithm) Design Process 1. Work out the answer for some examples. Look for a general principle
More informationCS 106 Winter 2016 Craig S. Kaplan. Module 01 Processing Recap. Topics
CS 106 Winter 2016 Craig S. Kaplan Moule 01 Processing Recap Topics The basic parts of speech in a Processing program Scope Review of syntax for classes an objects Reaings Your CS 105 notes Learning Processing,
More informationDefinition: A graph G = (V, E) is called a tree if G is connected and acyclic. The following theorem captures many important facts about trees.
Tree 1. Trees and their Properties. Spanning trees 3. Minimum Spanning Trees 4. Applications of Minimum Spanning Trees 5. Minimum Spanning Tree Algorithms 1.1 Properties of Trees: Definition: A graph G
More informationLecture 10. Elementary Graph Algorithm Minimum Spanning Trees
Lecture 10. Elementary Graph Algorithm Minimum Spanning Trees T. H. Cormen, C. E. Leiserson and R. L. Rivest Introduction to Algorithms, 3rd Edition, MIT Press, 2009 Sungkyunkwan University Hyunseung Choo
More informationBasic Graph Algorithms
Basic Graph Algorithms 1 Representations of Graphs There are two standard ways to represent a graph G(V, E) where V is the set of vertices and E is the set of edges. adjacency list representation adjacency
More informationPractical Session No. 12 Graphs, BFS, DFS, Topological sort
Practical Session No. 12 Graphs, BFS, DFS, Topological sort Graphs and BFS Graph G = (V, E) Graph Representations (V G ) v1 v n V(G) = V - Set of all vertices in G E(G) = E - Set of all edges (u,v) in
More informationIntroduction to Algorithms A graph G =(V, E) V = set of vertices E = set of edges
Introuction to Algorithms A graph G =(V, E) V = set of vertices E = set of eges In an unirecte graph: ege(u, v) = ege(v, u) Chapter 22: Elementary Graph Algorithms In a irecte graph: ege(u,v) goes from
More informationElements of Graph Theory
Elements of Graph Theory Quick review of Chapters 9.1 9.5, 9.7 (studied in Mt1348/2008) = all basic concepts must be known New topics we will mostly skip shortest paths (Chapter 9.6), as that was covered
More information6.854J / J Advanced Algorithms Fall 2008
MIT OpenCourseWare http://ocw.mit.edu 6.854J / 18.415J Advanced Algorithms Fall 2008 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms. 18.415/6.854 Advanced
More informationLecture 20 : Trees DRAFT
CS/Math 240: Introduction to Discrete Mathematics 4/12/2011 Lecture 20 : Trees Instructor: Dieter van Melkebeek Scribe: Dalibor Zelený DRAFT Last time we discussed graphs. Today we continue this discussion,
More informationDesign and Analysis of Algorithms
Design and Analysis of Algorithms CS 5311 Lecture 19 Topological Sort Junzhou Huang, Ph.D. Department of Computer Science and ngineering CS5311 Design and Analysis of Algorithms 1 Topological Sort Want
More informationCSCE 750, Fall 2002 Notes 6 Page Graph Problems ffl explore all nodes (breadth first and depth first) ffl find the shortest path from a given s
CSCE 750, Fall 2002 Notes 6 Page 1 10 Graph Algorithms (These notes follow the development in Cormen, Leiserson, and Rivest.) 10.1 Definitions ffl graph, directed graph (digraph), nodes, edges, subgraph
More information1. Lecture notes on bipartite matching
Massachusetts Institute of Technology 18.453: Combinatorial Optimization Michel X. Goemans February 5, 2017 1. Lecture notes on bipartite matching Matching problems are among the fundamental problems in
More informationimplementing the breadth-first search algorithm implementing the depth-first search algorithm
Graph Traversals 1 Graph Traversals representing graphs adjacency matrices and adjacency lists 2 Implementing the Breadth-First and Depth-First Search Algorithms implementing the breadth-first search algorithm
More informationDistributed Line Graphs: A Universal Technique for Designing DHTs Based on Arbitrary Regular Graphs
IEEE TRANSACTIONS ON KNOWLEDE AND DATA ENINEERIN, MANUSCRIPT ID Distribute Line raphs: A Universal Technique for Designing DHTs Base on Arbitrary Regular raphs Yiming Zhang an Ling Liu, Senior Member,
More informationReference Sheet for CO142.2 Discrete Mathematics II
Reference Sheet for CO14. Discrete Mathematics II Spring 017 1 Graphs Defintions 1. Graph: set of N nodes and A arcs such that each a A is associated with an unordered pair of nodes.. Simple graph: no
More informationDesign of Policy-Aware Differentially Private Algorithms
Design of Policy-Aware Differentially Private Algorithms Samuel Haney Due University Durham, NC, USA shaney@cs.ue.eu Ashwin Machanavajjhala Due University Durham, NC, USA ashwin@cs.ue.eu Bolin Ding Microsoft
More informationTrees. 3. (Minimally Connected) G is connected and deleting any of its edges gives rise to a disconnected graph.
Trees 1 Introduction Trees are very special kind of (undirected) graphs. Formally speaking, a tree is a connected graph that is acyclic. 1 This definition has some drawbacks: given a graph it is not trivial
More informationMatching Algorithms. Proof. If a bipartite graph has a perfect matching, then it is easy to see that the right hand side is a necessary condition.
18.433 Combinatorial Optimization Matching Algorithms September 9,14,16 Lecturer: Santosh Vempala Given a graph G = (V, E), a matching M is a set of edges with the property that no two of the edges have
More informationPERFECT ONE-ERROR-CORRECTING CODES ON ITERATED COMPLETE GRAPHS: ENCODING AND DECODING FOR THE SF LABELING
PERFECT ONE-ERROR-CORRECTING CODES ON ITERATED COMPLETE GRAPHS: ENCODING AND DECODING FOR THE SF LABELING PAMELA RUSSELL ADVISOR: PAUL CULL OREGON STATE UNIVERSITY ABSTRACT. Birchall an Teor prove that
More information3.1 Basic Definitions and Applications
Graphs hapter hapter Graphs. Basic efinitions and Applications Graph. G = (V, ) n V = nodes. n = edges between pairs of nodes. n aptures pairwise relationship between objects: Undirected graph represents
More informationOnline Appendix to: Generalizing Database Forensics
Online Appenix to: Generalizing Database Forensics KYRIACOS E. PAVLOU an RICHARD T. SNODGRASS, University of Arizona This appenix presents a step-by-step iscussion of the forensic analysis protocol that
More informationRepresentations of Graphs
ELEMENTARY GRAPH ALGORITHMS -- CS-5321 Presentation -- I am Nishit Kapadia Representations of Graphs There are two standard ways: A collection of adjacency lists - they provide a compact way to represent
More informationGraph and Digraph Glossary
1 of 15 31.1.2004 14:45 Graph and Digraph Glossary A B C D E F G H I-J K L M N O P-Q R S T U V W-Z Acyclic Graph A graph is acyclic if it contains no cycles. Adjacency Matrix A 0-1 square matrix whose
More informationPrinciples of B-trees
CSE465, Fall 2009 February 25 1 Principles of B-trees Noes an binary search Anoe u has size size(u), keys k 1,..., k size(u) 1 chilren c 1,...,c size(u). Binary search property: for i = 1,..., size(u)
More informationGraphs. Part I: Basic algorithms. Laura Toma Algorithms (csci2200), Bowdoin College
Laura Toma Algorithms (csci2200), Bowdoin College Undirected graphs Concepts: connectivity, connected components paths (undirected) cycles Basic problems, given undirected graph G: is G connected how many
More informationCHENNAI MATHEMATICAL INSTITUTE M.Sc. / Ph.D. Programme in Computer Science
CHENNAI MATHEMATICAL INSTITUTE M.Sc. / Ph.D. Programme in Computer Science Entrance Examination, 5 May 23 This question paper has 4 printed sides. Part A has questions of 3 marks each. Part B has 7 questions
More information6. Lecture notes on matroid intersection
Massachusetts Institute of Technology 18.453: Combinatorial Optimization Michel X. Goemans May 2, 2017 6. Lecture notes on matroid intersection One nice feature about matroids is that a simple greedy algorithm
More informationGraphs and Network Flows IE411. Lecture 21. Dr. Ted Ralphs
Graphs and Network Flows IE411 Lecture 21 Dr. Ted Ralphs IE411 Lecture 21 1 Combinatorial Optimization and Network Flows In general, most combinatorial optimization and integer programming problems are
More informationMathematical and Algorithmic Foundations Linear Programming and Matchings
Adavnced Algorithms Lectures Mathematical and Algorithmic Foundations Linear Programming and Matchings Paul G. Spirakis Department of Computer Science University of Patras and Liverpool Paul G. Spirakis
More informationCOL 702 : Assignment 1 solutions
COL 70 : Assignment 1 solutions 1(a ( n T (n = T + bn log n ( n = T + b n ( n log + bn log n ( n = T + b n ( n 8 log + b n log ( n + bn log n = bn log n + b n log n + bn log n +... log n terms = nb [(log
More informationGraph Algorithms. Definition
Graph Algorithms Many problems in CS can be modeled as graph problems. Algorithms for solving graph problems are fundamental to the field of algorithm design. Definition A graph G = (V, E) consists of
More informationUndirected Graphs. DSA - lecture 6 - T.U.Cluj-Napoca - M. Joldos 1
Undirected Graphs Terminology. Free Trees. Representations. Minimum Spanning Trees (algorithms: Prim, Kruskal). Graph Traversals (dfs, bfs). Articulation points & Biconnected Components. Graph Matching
More informationDHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI. Department of Computer Science and Engineering CS6301 PROGRAMMING DATA STRUCTURES II
DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI Department of Computer Science and Engineering CS6301 PROGRAMMING DATA STRUCTURES II Anna University 2 & 16 Mark Questions & Answers Year / Semester: II / III
More informationShortest path problems
Next... Shortest path problems Single-source shortest paths in weighted graphs Shortest-Path Problems Properties of Shortest Paths, Relaxation Dijkstra s Algorithm Bellman-Ford Algorithm Shortest-Paths
More informationSolution for Homework set 3
TTIC 300 and CMSC 37000 Algorithms Winter 07 Solution for Homework set 3 Question (0 points) We are given a directed graph G = (V, E), with two special vertices s and t, and non-negative integral capacities
More informationNon-homogeneous Generalization in Privacy Preserving Data Publishing
Non-homogeneous Generalization in Privacy Preserving Data Publishing W. K. Wong, Nios Mamoulis an Davi W. Cheung Department of Computer Science, The University of Hong Kong Pofulam Roa, Hong Kong {wwong2,nios,cheung}@cs.hu.h
More informationLoop Scheduling and Partitions for Hiding Memory Latencies
Loop Scheuling an Partitions for Hiing Memory Latencies Fei Chen Ewin Hsing-Mean Sha Dept. of Computer Science an Engineering University of Notre Dame Notre Dame, IN 46556 Email: fchen,esha @cse.n.eu Tel:
More informationRepresentations of Weighted Graphs (as Matrices) Algorithms and Data Structures: Minimum Spanning Trees. Weighted Graphs
Representations of Weighted Graphs (as Matrices) A B Algorithms and Data Structures: Minimum Spanning Trees 9.0 F 1.0 6.0 5.0 6.0 G 5.0 I H 3.0 1.0 C 5.0 E 1.0 D 28th Oct, 1st & 4th Nov, 2011 ADS: lects
More informationMatching Theory. Figure 1: Is this graph bipartite?
Matching Theory 1 Introduction A matching M of a graph is a subset of E such that no two edges in M share a vertex; edges which have this property are called independent edges. A matching M is said to
More informationThomas H. Cormen Charles E. Leiserson Ronald L. Rivest. Introduction to Algorithms
Thomas H. Cormen Charles E. Leiserson Ronald L. Rivest Introduction to Algorithms Preface xiii 1 Introduction 1 1.1 Algorithms 1 1.2 Analyzing algorithms 6 1.3 Designing algorithms 1 1 1.4 Summary 1 6
More informationTreewidth and graph minors
Treewidth and graph minors Lectures 9 and 10, December 29, 2011, January 5, 2012 We shall touch upon the theory of Graph Minors by Robertson and Seymour. This theory gives a very general condition under
More informationLecture 10 Graph algorithms: testing graph properties
Lecture 10 Graph algorithms: testing graph properties COMP 523: Advanced Algorithmic Techniques Lecturer: Dariusz Kowalski Lecture 10: Testing Graph Properties 1 Overview Previous lectures: Representation
More informationIntroduction to Parallel & Distributed Computing Parallel Graph Algorithms
Introduction to Parallel & Distributed Computing Parallel Graph Algorithms Lecture 16, Spring 2014 Instructor: 罗国杰 gluo@pku.edu.cn In This Lecture Parallel formulations of some important and fundamental
More informationGraph. Vertex. edge. Directed Graph. Undirected Graph
Module : Graphs Dr. Natarajan Meghanathan Professor of Computer Science Jackson State University Jackson, MS E-mail: natarajan.meghanathan@jsums.edu Graph Graph is a data structure that is a collection
More informationv V Question: How many edges are there in a graph with 10 vertices each of degree 6?
ECS20 Handout Graphs and Trees March 4, 2015 (updated 3/9) Notion of a graph 1. A graph G = (V,E) consists of V, a nonempty set of vertices (or nodes) and E, a set of pairs of elements of V called edges.
More informationAlgorithms (VII) Yijia Chen Shanghai Jiaotong University
Algorithms (VII) Yijia Chen Shanghai Jiaotong University Review of the Previous Lecture Depth-first search in undirected graphs Exploring graphs explore(g, v) Input: G = (V, E) is a graph; v V Output:
More information