Low-Stretch Spanning Tree on Benchmark Circuits

Size: px
Start display at page:

Download "Low-Stretch Spanning Tree on Benchmark Circuits"

Transcription

1 Low-Stretch Spanning Tree on Benchmark Circuits Yujie An and Igor Markov Department of Electrical Engineering and Computer Science University of Michigan July 8, 2013 Abstract We show the testing results of Kruskal, Prim-Dijkstra for finding a low-stretch spanning tree for both unweighted graphs and weighted graphs transformed from benchmark circuits [1]. On unweighted graph, our implementation can get an average stretch of about 7 for all benchmark circuits. Kruskal s algorithm gives good edge selection for finding short stretch edges, but does not work well for other large stretch edges. Prim-Dijkstra algorithm works well on Dijkstra s part, but not well on Prim s part. The shortest path algorithm may not give minimum spanning tree, but it can keep the average stretch of off-tree edges very small. On random weighted graph, in which all edges are given a random weight, our implementation can get an average stretch of about 6.5 for all benchmark circuits. This result is even better than unweighted graphs. Prim-Dijkstra algorithm works better than Kruskal s algorithm, and this is mostly due to Dijkstra s shortest path. What s more, a ratio for about can make Prim-Dijkstra algorithm works even better. The low-stretch spanning tree we get is a shortest path tree, with a slightly variation to minimum spanning tree. 1 Introduction Let G = (V, E, d) be a graph (unweighted or weighted), where d : E R + assigns a positive length to each edge (d = 1 for unweighted graph). Given a graph G of V, the distance in G between a pair of vertices u, v V, denoted by dist G (u, v), is defined as the sum of the lengths of of the edges on the shortest path in G between u and v. Given a spanning tree T, we can then define the stretch of an edge (u, v) E to be [2] stretch T (u, v) = dist T (u, v). d(u, v) Note that this definition of the stretch differs slightly from the best-known one, as used in [3], and [2] discusses their difference. The average stretch over all edges of E is defined to be [3] avg-stretch T (E) = 1 E Moreover, we define the eccentricity ɛ(v) to be (u,v) E ɛ(v) = max u V {dist G(u, v)}, stretch T (u, v). 1 which can be seen as the distance from that vertex to the farthest vertex. The diameter of a graph is the maximum eccentricity of any vertex in the graph, and a central point is the mid vertex (or one of the mid vertices) on the diameter. anyujie@umich.edu, imarkov@eecs.umich.edu 1 This may appear as ave-stretch later, which is used in [3]. 1

2 2 Background We want to find a low-stretch spanning tree for benchmark circuits, and make sure that the average stretch of the tree is actually low enough. Thus, both tree finding and stretch calculating algorithms are needed. 2.1 Finding a Low-Stretch Spanning Tree We construct our low-stretch spanning tree by Kruskal and Prim-Dijkstra algorithm. Kruskal s algorithm [4] is one of the most well-known algorithms that can find a minimum spanning tree of a graph. Prim-Dijkstra algorithm is a mix of Prim s algorithm [5] and Dijkstra s algorithm [6], with a real number weight w from 0 to 1, using w d[v, s]+(1 w) d[v, T ] for next point selection, instead of d[v, s] in Dijkstra s algorithm and d[v, T ] in Prim s algorithm. Using weighted sum of distances as priority can take advantage of both Dijkstra s and Prim s algorithm, and are more likely to find a lower average stretch tree. 2.2 Calculating Average Stretch We only need to calculate the total stretch. Given a tree, we randomly select a root r, and construct a tree structure according to r. For every edge in the original graph, the stretch for that edge is stretch T (u, v) = d T (u, r) + d T (v, r) 2 d T (LCA(u, v), r), d(u, v) in which LCA represents Lowest Common Ancestor [7]. Since all d T (x, r) can be pre-calculated in O(n), the problem now is to find the LCA(a, b) as fast as possible. There are several well-known ways to find the LCA in O(n log n) O(log n) or O(n) O(1) times, where first O represents pre-calculation complexity, and second O represents one query complexity. For the O(n log n) O(log n) algorithm, it uses dynamic programming, which is very similar to sparse table method of Range Minimum Query (RMQ) [8] problem. For each vertex x, T [x] represent the father of x in the tree, and we don t care the father of root, which would never be used for querying. In this way, we pre-calculate P [i][j] as P [i][j] = { T [i], j = 0, P [P [i][j 1]][j 1], j > 0. We then define L[x] be the level of vertex x in the tree. We can see that if two vertices a, b are in the same level, we can calculate LCA(a, b) by binary search. Therefore, we first make two queried vertices into the same level. Without losing generality, we assume that L[a] < L[b], we can use binary search for finding the ancestor of b situated on the same level of a. After that, for every power j of 2 (between log(l[a]) and 0, in descing order), if P [a][j] P [b][j] then we know that LCA(a, b) is on a higher level and we will continue searching for LCA(a = P [a][j], b = P [b][j]). At the, both a and b will have the same father, so return T [a]. More details and implementations can be found at [9]. For the O(n) O(1) algorithm, it first changes LCA to restricted RMQ in O(n), then solve each query in restricted RMQ in O(1). More details can be found at [9]. However, this algorithm is not as fast as we thought it would be, because it probably has a pretty big constant when queried. As we can see, for each query, it needs at most four random accesses to two huge arrays. This means if our log n factor is much smaller than 4, O(log n) query would work better. We will not go into details, but our implementation shows that O(n log n) O(log n) query works better, and we will stick to this algorithm in future. 3 Unweighted Graph Analysis In this section, we will show our results in unweighted graphs generated by benchmark circuits [1]. All the resulting data, including average stretch, longest stretch, diameter, stretch distribution, will 2

3 be shown. 3.1 Unweighted Graph Parser We use a very simple parser to get an unweighted graph from benchmarks. For all nodes that already exist, we give it a corresponding vertex in our unweighted graph. For all edges in nets, if the edge is a hyperedge, we give a new vertex representing the center of the hyperedge, and give an edge from this center to each vertex on this hyperedge; if the edge is not a hyperedge, we connect them. Unfortunately, the graph parsed in this way is not connected, and it always contains a huge connected component, which contains almost 99% of all vertices, and lots of small components. To simplify the problem, we filter out all small components, and leave only the largest connected component. 3.2 Original Graph Information Table 1 shows the parsed input graph size of benchmark circuits [1]. (* is the data after filtering.) Table 1: Benchmark circuit input graph size Benchmark No. Num. of Vertices Num. of Edges Num. of Vertices* Num. of Edges* Unweighted Central Vertex Heuristics All of our algorithms use a central vertex heuristic. This is a heuristic that can significantly decrease the average stretch of the spanning tree generated by Kruskal s algorithm, and slightly optimize the result of Prim-Dijkstra algorithm. To apply this heuristic, we need to detect the radius of the graph first. We define radius by first finding it. Starting at a random vertex, by using breath first search (BFS), we can find the furthest vertex from it. Save this point and the length of this path. Note that when meeting a tie, randomly select one vertex for the next start. Different selection would sometimes affect the result. After that, we keep doing new BFS start from the vertex obtained from last BFS, until the furthest point s distance does not change any more. We define radius be a tuple of (s, t, d), where s is the start point, t is the point, and d is the shortest distance between them. Finally, the last BFS would give us a radius with d be about half of the length of real diameter. After finding the radius of the graph, we actually have two ways to define our heuristic number. 1) We perform another two BFS from both s and t of the radius, and give a heuristic number to all vertices in the graph. The heuristic number is the larger one of the two distances from each s of radius. 2) We perform only one BFS from either s or t of the radius, and give a heuristic number of abs(d k), where d is in radius, k is the distance from that vertex to the start point now, and abs is the absolute value. Finally, we choose the vertex with the smallest heuristic number to be the start vertex of Prim- Dijkstra algorithm, and sort all edges according to the sum of heuristic numbers of two vertices on the edge, from small to large, for Kruskal s algorithm. In fact, heuristic 1 works better than heuristic 2 in practice, and we will show the result later. 3

4 3.4 Kruskal s algorithm In this section, we will give our implementation of Kruskal s algorithm and its results Pseudocode for Kruskal s algorithm Data: Graph G Result: a spanning tree of G sort-edges-by-heuristic A for v V do makeset(v) for e E do if set(v1) set(v2) then A A + make-edge(v1, v2) union(v1, v2) return A Algorithm 1: Kruskal s algorithm Runtime results Testing OS: Red Hat Enterprise Linux Workstation release 6.4. CPU model: Intel(R) Xeon(R) CPU E GHz. CPU MHz: Cache Size: 8 MB. CPU Number: 4. Table 2 shows a onetime result of Kruskal s algorithm using heuristic No.1. (Note: R represents runtime, and it s in seconds. R1 is runtime for finding a central vertex, R2 is runtime for Kruskal s algorithm and R3 is runtime for calculating average stretch.) Table 2: Result of Kruskal s algorithm unweighted version No.1 Benchmark No. Avg-Stretch Longest Stretch Diameter R1 R2 R Table 3 shows a onetime result of Kruskal s algorithm using heuristic No.2. 4

5 Table 3: Result of Kruskal s algorithm unweighted version No.2 Benchmark No. Avg-Stretch Longest Stretch Diameter R1 R2 R We can see that heuristic No.2 generally does not work well for Kruskal s algorithm, but it can sometime work better, as in benchmark No.5. Since it runs fast, it is probably a good idea to run both heuristics and find the better result. We will go into more details in Prim-Dijkstra algorithm, since heuristic No.2 works much better there Off-tree edges stretch distribution Kruskal In order to know whether we can add some off-tree edges to significantly reduce the average stretch, we get the following figures. Figure 1 gives off-tree edges stretch distribution for benchmark 1.. (All following data are obtained using heuristic No.1.) Figure 1: Stretch distribution for benchmark 1 unweighted version Kruskal It seems that the distribution is reasonable, most of the stretches are close to the average, and there is no very long stretch. To verify this, we can see another Figure 2 for benchmark Figure 2: Stretch distribution for benchmark 7 unweighted version Kruskal 5

6 According to this graph, we know that our central vertex heuristic works pretty well for Kruskal s algorithm to make most stretches small and close to the average. However, the longest stretches are very long, which means that simple sort for edges by the central vertex heuristic would result in not considering some edges, so that their stretches would be significantly long. We will compare this with Prim-Dijkstra later. 3.5 Prim-Dijkstra algorithm In this section, we will give our implementation of Prim-Dijkstra algorithm and its results Pseudocode for Prim-Dijkstra algorithm Here is the pseudocode for our Prim-Dijkstra algorithm. Note that when calculating heuristicdistance d, we use the weighted sum of the heuristic-distance from that vertex to source and to tree. The sum should be d[v] = d[current] w + dist[current, v] (1 w), since in this way, the source distance can be reduced by a factor of w, and after the reduction its significance can be compared with tree distance. If we purely use distance d and calculate heuristic-distance h = d[current] w + dist[current, v] (1 w), then after a few iteration, d[current] would grow so big that dist[current, v] would have very tiny effect on h. Data: Graph G, Ratio w Result: a spanning tree of G source Central-Finding-Heuristic(G) T d[1... V ] = father[1... V ] = 1 d[source] = 0 for v / T do current vertex with minimum d if current does not exist then break T T + current for all neighbor v of current do if d[v] > d[current] w + dist[current, v] (1 w) then d[v] = d[current] w + dist[current, v] (1 w) f ather[v] = current A for v V do if father[v] -1 then A make-edge(v, father[v]) return A Algorithm 2: Prim-Dijkstra algorithm Runtime results Table 4 shows the runtime result for Prim-Dijkstra algorithm, with w = 1 and heuristic No.1. (Note: same as before, R represents runtime, and it s in seconds. R1 is runtime for finding a central vertex, R2 is runtime for Prim-Dijkstra algorithm and R3 is runtime for calculating average stretch.) 6

7 Table 4: Result of Prim-Dijkstra algorithm unweighted version with w = 1 No.1 Benchmark No. Avg-Stretch Longest Stretch Diameter R1 R2 R Table 5 shows the runtime result for heuristic No.2. Table 5: Result of Prim-Dijkstra algorithm unweighted version with w = 1 No.2 Benchmark No. Avg-Stretch Longest Stretch Diameter R1 R2 R As we can see, for benchmark 4, 7, 16, heuristic No.2 works better than heuristic No.1, and it almost significantly reduce the average stretch of benchmark 7. Therefore, it is a good idea to run both heuristics and return the better result Different weights effect on average stretch In order to find the best ratio w, we tested 101 different w from 0 to 1, 0.01 scaled. Figure 3 shows the ratio plot for benchmark 1 generated by our Prim-Dijkstra algorithm. As we can see, the method Figure 3: Ratio plot for benchmark 1 unweighted version 7

8 does not work well on unweighted graph. The reason is actually quite simple: on unweighted graph, all weights can be seen as 1, and in this way, Prim s algorithm is actually pure random. The result is not terribly bad because we have the central vertex heuristic, and if we delete the heuristic and start from a random point, the average stretch would be extremely long. We will go back to this in detail in weighted graphs Off-tree edges stretch distribution Prim-Dijkstra Same reason as for Kruskal, we calculate this stretch distribution (Figure 4) for Prim-Dijkstra algorithm. (Using heuristic No.1.) Figure 4: Stretch distribution for benchmark 1 unweighted version Prim-Dijkstra It seems that the distribution is quite even, and there is no off-tree edges that have a significant large stretch. Figure 5 is another plot for benchmark 7, the largest one of all benchmarks Figure 5: Stretch distribution for benchmark 7 unweighted version Prim-Dijkstra It seems that there are some edges that have pretty large stretch, and it is intuitive to guess that these edges are connecting two parts far from the center, and also far from each other. We believe that this attribute would become more obvious when dealing with weighted graphs, and we would then try to figure out whether we could add in some off-tree edges so that we can significantly reduce the average stretch. Comparing to Kruskal s result, Prim-Dijkstra algorithm is actually much better. For the lowstretch edges whose stretches are less than 17.5, the total number is generally the same. However, Prim-Dijkstra works better for larger stretch. This suggests that we should need something that is similar to the shortest path when finding a low-stretch spanning tree, not only minimun spanning tree. 8

9 4 Weighted Graph Analysis Random Length In this section, we will show our results in weighted graphs generated by benchmark circuits [1]. All edges lengths are generated by normal distribution generator. 4.1 Random Length Weighted Graph Parser This parser is almost exactly the same as our unweighted graph parser, except that it gives a random length to each edge. The random numbers are generated by normal distribution, with mean µ = 100, and standard deviation σ = 20. Also, we check whether it would generate some negative numbers, though with extremely small probability. If this happens, we set the length to another random number from the distribution. There is one more thing that needs to be mentioned. Our parser works only one time, which means that the input data for the following algorithms keep the same all the time, without randomness. 4.2 Original Graph Information Table 6 shows the parsed input graph information after filtering. Table 6: Benchmark circuit input graph information random length Benchmark Num. of Vertices Num. of Edges Average Length Longest Edge Shortest Edge Weighted Central Vertex Heuristics The central vertex heuristic becomes more complex in weighted graphs. We defined the unweighted central vertex heuristic number be the number we calculated by our previous central vertex heuristics. We now define the weighted central vertex heuristic number as follows. We keep the definition of radius the same as before. For weighted graphs, instead of BFS, we use Dijkstra s algorithm for each search, and finish until the longest distance does not change any more. This would give us a radius. After finding the radius, we still have two ways to define our heuristic number. 1) We perform another two Dijkstra s algorithm from both s and t of the radius, and give a heuristic number to all vertices in the graph. The heuristic number is the larger one of the two distances from each s of radius. 2) We perform only one Dijkstra s algorithm from either s or t of the radius, and give a heuristic number of abs(d k), where d is in radius, k is the distance from that vertex to the start point now, and abs is the absolute value. All the left parts remain the same, we sort the edges according to their heuristic numbers, and return a central point. 4.4 Kruskal s algorithm In this section, we give our results of Kruskal s algorithm on random weighted graphs parsed from benchmark circuits. Note that our Kruskal s algorithm now is pretty far away from the original one, 9

10 and only core idea of union find set remains. We sort the edges by their heuristics, not their lengths, so that the tree we get is expected to be a low-stretch spanning tree, not a minimum spanning tree Runtime results Table 7 shows a onetime result of Kruskal s algorithm using unweighted heuristic No.1. Still, R1 is runtime for finding a central vertex, R2 is runtime for Kruskal s algorithm and R3 is runtime for calculating average stretch. Table 7: Result of Kruskal s algorithm random weighted version No.1 Benchmark No. Avg-Stretch Longest Stretch Diameter R1 R2 R Table 8 shows results of four different heuristics. No.1 and No.2 are unweighted heuristics, and No.3 and No.4 are weighted heuristics. Table 8: Different heuristics results of Kruskal s algorithm random weighted version Benchmark No. Heuristic No.1 Heuristic No.2 Heuristic No.3 Heuristic No Different weights effect on average stretch As we can see, weighted heuristic No.1 works the best for most of benchmark circuits. However, up to now, we have not used the power of Kruskal s algorithm in finding a minimum spanning tree. In unweighted graphs, this power is very small because Kruskal s algorithm is no more than a random edge selection with union find set. In weighted graphs, things change since every edge has a length, so that the mimimum property of the spanning tree may be important now. We redefine our heuristic number for weighted heuristic No.1 be a weighted sum of h[x] = h [x] w + d[x] (1 w) for each edge x, in which h is the heuristic number now, h is the previous heuristic number, and d is the length of that edge. In this way, when w = 1, it is the weighted heuristic No.1 before; when w = 0, it is pure Kruskal s algorithm. Figure 6 gives all plots on different weights effect on Kruskal s algorithm for all eight benchmarks. As we can see, 0.2 seems to be a very good weight. Table 9 gives the best results over different weights of Kruskal s algorithm. Note that all results are obtained by using weighted heuristic No.1. Since it is the best results, it would be helpful to give the average results of all benchmarks at the. Note that the means are calculated after eliminating the largest and the smallest data. 10

11 Figure 6: Different weights effect on average stretch random weighted version Kruskal 11

12 Table 9: Best results of Kruskal s algorithm random weighted version Benchmark No. Weight Avg-stretch Mean Median Off-tree edges stretch distribution Kruskal Same as unweighted version, we get the off-tree edge stretch distribution. Figure 7 shows the off-tree edges stretch distribution for random weighted graphs from benchmark 1 for Kruskal s algorithm. This figure is obtained by weighted heuristic No.1, with w = Figure 7: Stretch distribution for benchmark 1 random weighted version Kruskal As we can see from the right most of the figure, there are some edges that have very long stretches. To assure this, we get another Figure 8 for benchmark 7, with w = Figure 8: Stretch distribution for benchmark 7 random weighted version Kruskal It is very similar to benchmark 1. They suggest that finding a way to reduce the number of edges with very long stretches would be important. 12

13 4.5 Prim-Dijkstra algorithm In this section, we give our results of Prim-Dijkstra algorithm on random weighted graphs parsed from benchmark circuits Runtime results Table 10 shows a onetime result of Prim-Dijkstra algorithm using unweighted heuristic No.1. Still, R1 is runtime for finding a central vertex, R2 is runtime for Kruskal s algorithm and R3 is runtime for calculating average stretch. The results we get here are all with w = 1, though we will show later that this is not the best ratio now. Table 10: Result of Prim-Dijkstra algorithm random weighted version No.1 Benchmark No. Avg-Stretch Longest Stretch Diameter R1 R2 R Table 11 shows results of four different heuristics. No.1 and No.2 are unweighted heuristics, and No.3 and No.4 are weighted heuristics. Table 11: Different heuristics results of Prim-Dijkstra algorithm random weighted version Benchmark No. Heuristic No.1 Heuristic No.2 Heuristic No.3 Heuristic No Different weights effect on average stretch To be consistent with Kruskal s algorithm, we first get the ratio plot for weighted heuristic No.1. Figure 9 shows the result. Though the tency differs in different benchmarks, we can still see that ratio about works the best. Note that this result means that the algorithm mostly runs on Dijkstra s, with a slightly variation to Prim s algorithm. To go into more details, we give another plot for unweighted heuristic No.1, which work best for Prim-Dijkstra algorithm according to Table 11. Figure 9 shows the result. Generally the tr keeps the same and the results are better. Table 12 gives the best results over different weights of Prim-Dijkstra algorithm obtained by unweighted heuristic No.1. Same as before, we give the mean at the. The means are still calculated after eliminating the largest and the smallest data. 13

14 Table 12: Best results of Prim-Dijkstra algorithm random weighted version Benchmark No. Weight Avg-stretch Mean Median Off-tree edges stretch distribution Prim-Dijkstra Same as before, we get Figure 11 and Figure 12. As we can see, Prim-Dijkstra algorithm could give us a better off-tree stretch distribution than Kruskal s algorithm. References [1] Natarajan Viswanathan (2012). Design Hierarchy Aware Routability-driven Placement. Accessed May 20, 2013, at CAD-contest-at-ICCAD2012/problems/p2/p2.html. [2] Michael Elkin, Yuval Emek, Daniel A. Spielman, and Shang-Hua Teng. Lower-stretch spanning trees. STOC 05: Proceedings of the thirty-seventh annual ACM symposium on Theory of computing, pages , New York, New York, USA. [3] Ittai Abraham & Ofer Neiman (2012). Using Petal-Decompositions to Build a Low Stretch Spanning Tree. STOC 12, May 12-22, 2012, New York, New York, USA. [4] Kruskal s algorithm. Accessed May 20, 2013, at s_ algorithm. [5] Prim s algorithm. Accessed May 20, 2013, at algorithm. [6] Dijkstra s algorithm. Accessed May 20, 2013, at 27s_algorithm. [7] Lowest common ancestor. Accessed May 20, 2013, at Lowest_common_ancestor. [8] Range Minimum Query. Accessed May 20, 2013, at Minimum_Query. [9] Range Minimum Query and Lowest Common Ancestor. Accessed May 20, 2013, at http: //community.topcoder.com/tc?module=static&d1=tutorials&d2=lowestcommonancestor. 14

15 Figure 9: Different weights effect on average stretch random weighted version Prim-Dijkstra by weighted No.1 15

16 Figure 10: Different weights effect on average stretch random weighted version Prim-Dijkstra by unweighted No.1 16

17 Figure 11: Stretch distribution for benchmark 1 random weighted version Prim-Dijkstra Figure 12: Stretch distribution for benchmark 7 random weighted version Prim-Dijkstra 17

CSE 100 Minimum Spanning Trees Prim s and Kruskal

CSE 100 Minimum Spanning Trees Prim s and Kruskal CSE 100 Minimum Spanning Trees Prim s and Kruskal Your Turn The array of vertices, which include dist, prev, and done fields (initialize dist to INFINITY and done to false ): V0: dist= prev= done= adj:

More information

Minimum spanning trees

Minimum spanning trees Carlos Moreno cmoreno @ uwaterloo.ca EI-3 https://ece.uwaterloo.ca/~cmoreno/ece5 Standard reminder to set phones to silent/vibrate mode, please! During today's lesson: Introduce the notion of spanning

More information

Low-Stretch Spanning Trees

Low-Stretch Spanning Trees Eötvös Loránd University Faculty of Science Low-Stretch Spanning Trees Pál András Papp BSc thesis Advisors: Sándor Kisfaludi-Bak Zoltán Király Department of Computer Science Budapest, May 2014 Contents

More information

Lecture 13. Reading: Weiss, Ch. 9, Ch 8 CSE 100, UCSD: LEC 13. Page 1 of 29

Lecture 13. Reading: Weiss, Ch. 9, Ch 8 CSE 100, UCSD: LEC 13. Page 1 of 29 Lecture 13 Connectedness in graphs Spanning trees in graphs Finding a minimal spanning tree Time costs of graph problems and NP-completeness Finding a minimal spanning tree: Prim s and Kruskal s algorithms

More information

CS 310 Advanced Data Structures and Algorithms

CS 310 Advanced Data Structures and Algorithms CS 0 Advanced Data Structures and Algorithms Weighted Graphs July 0, 07 Tong Wang UMass Boston CS 0 July 0, 07 / Weighted Graphs Each edge has a weight (cost) Edge-weighted graphs Mostly we consider only

More information

4/8/11. Single-Source Shortest Path. Shortest Paths. Shortest Paths. Chapter 24

4/8/11. Single-Source Shortest Path. Shortest Paths. Shortest Paths. Chapter 24 /8/11 Single-Source Shortest Path Chapter 1 Shortest Paths Finding the shortest path between two nodes comes up in many applications o Transportation problems o Motion planning o Communication problems

More information

Lecture 6 Basic Graph Algorithms

Lecture 6 Basic Graph Algorithms CS 491 CAP Intro to Competitive Algorithmic Programming Lecture 6 Basic Graph Algorithms Uttam Thakore University of Illinois at Urbana-Champaign September 30, 2015 Updates ICPC Regionals teams will be

More information

Chapter 9 Graph Algorithms

Chapter 9 Graph Algorithms Chapter 9 Graph Algorithms 2 Introduction graph theory useful in practice represent many real-life problems can be slow if not careful with data structures 3 Definitions an undirected graph G = (V, E)

More information

Depth First Search A B C D E F G A B C 5 D E F 3 2 G 2 3

Depth First Search A B C D E F G A B C 5 D E F 3 2 G 2 3 Depth First Search A B C D E F G A 4 3 2 B 4 5 4 3 C 5 D 3 4 2 E 2 2 3 F 3 2 G 2 3 Minimum (Weight) Spanning Trees Let G be a graph with weights on the edges. We define the weight of any subgraph of G

More information

Chapter 9 Graph Algorithms

Chapter 9 Graph Algorithms Chapter 9 Graph Algorithms 2 Introduction graph theory useful in practice represent many real-life problems can be if not careful with data structures 3 Definitions an undirected graph G = (V, E) is a

More information

11/22/2016. Chapter 9 Graph Algorithms. Introduction. Definitions. Definitions. Definitions. Definitions

11/22/2016. Chapter 9 Graph Algorithms. Introduction. Definitions. Definitions. Definitions. Definitions Introduction Chapter 9 Graph Algorithms graph theory useful in practice represent many real-life problems can be slow if not careful with data structures 2 Definitions an undirected graph G = (V, E) is

More information

CS161 - Minimum Spanning Trees and Single Source Shortest Paths

CS161 - Minimum Spanning Trees and Single Source Shortest Paths CS161 - Minimum Spanning Trees and Single Source Shortest Paths David Kauchak Single Source Shortest Paths Given a graph G and two vertices s, t what is the shortest path from s to t? For an unweighted

More information

Chapter 9 Graph Algorithms

Chapter 9 Graph Algorithms Introduction graph theory useful in practice represent many real-life problems can be if not careful with data structures Chapter 9 Graph s 2 Definitions Definitions an undirected graph is a finite set

More information

tree follows. Game Trees

tree follows. Game Trees CPSC-320: Intermediate Algorithm Design and Analysis 113 On a graph that is simply a linear list, or a graph consisting of a root node v that is connected to all other nodes, but such that no other edges

More information

CS 5321: Advanced Algorithms Minimum Spanning Trees. Acknowledgement. Minimum Spanning Trees

CS 5321: Advanced Algorithms Minimum Spanning Trees. Acknowledgement. Minimum Spanning Trees CS : Advanced Algorithms Minimum Spanning Trees Ali Ebnenasir Department of Computer Science Michigan Technological University Acknowledgement Eric Torng Moon Jung Chung Charles Ofria Minimum Spanning

More information

Dijkstra s algorithm for shortest paths when no edges have negative weight.

Dijkstra s algorithm for shortest paths when no edges have negative weight. Lecture 14 Graph Algorithms II 14.1 Overview In this lecture we begin with one more algorithm for the shortest path problem, Dijkstra s algorithm. We then will see how the basic approach of this algorithm

More information

A Clustering Approach to the Bounded Diameter Minimum Spanning Tree Problem Using Ants. Outline. Tyler Derr. Thesis Adviser: Dr. Thang N.

A Clustering Approach to the Bounded Diameter Minimum Spanning Tree Problem Using Ants. Outline. Tyler Derr. Thesis Adviser: Dr. Thang N. A Clustering Approach to the Bounded Diameter Minimum Spanning Tree Problem Using Ants Tyler Derr Thesis Adviser: Dr. Thang N. Bui Department of Math & Computer Science Penn State Harrisburg Spring 2015

More information

Lecture Summary CSC 263H. August 5, 2016

Lecture Summary CSC 263H. August 5, 2016 Lecture Summary CSC 263H August 5, 2016 This document is a very brief overview of what we did in each lecture, it is by no means a replacement for attending lecture or doing the readings. 1. Week 1 2.

More information

CSE 100: GRAPH ALGORITHMS

CSE 100: GRAPH ALGORITHMS CSE 100: GRAPH ALGORITHMS Dijkstra s Algorithm: Questions Initialize the graph: Give all vertices a dist of INFINITY, set all done flags to false Start at s; give s dist = 0 and set prev field to -1 Enqueue

More information

CS200: Graphs. Rosen Ch , 9.6, Walls and Mirrors Ch. 14

CS200: Graphs. Rosen Ch , 9.6, Walls and Mirrors Ch. 14 CS200: Graphs Rosen Ch. 9.1-9.4, 9.6, 10.4-10.5 Walls and Mirrors Ch. 14 Trees as Graphs Tree: an undirected connected graph that has no cycles. A B C D E F G H I J K L M N O P Rooted Trees A rooted tree

More information

Chapter 9. Greedy Technique. Copyright 2007 Pearson Addison-Wesley. All rights reserved.

Chapter 9. Greedy Technique. Copyright 2007 Pearson Addison-Wesley. All rights reserved. Chapter 9 Greedy Technique Copyright 2007 Pearson Addison-Wesley. All rights reserved. Greedy Technique Constructs a solution to an optimization problem piece by piece through a sequence of choices that

More information

Introduction to Algorithms / Algorithms I Lecturer: Michael Dinitz Topic: Shortest Paths Date: 10/13/15

Introduction to Algorithms / Algorithms I Lecturer: Michael Dinitz Topic: Shortest Paths Date: 10/13/15 600.363 Introduction to Algorithms / 600.463 Algorithms I Lecturer: Michael Dinitz Topic: Shortest Paths Date: 10/13/15 14.1 Introduction Today we re going to talk about algorithms for computing shortest

More information

CS521 \ Notes for the Final Exam

CS521 \ 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 information

Dijkstra s Algorithm Last time we saw two methods to solve the all-pairs shortest path problem: Min-plus matrix powering in O(n 3 log n) time and the

Dijkstra s Algorithm Last time we saw two methods to solve the all-pairs shortest path problem: Min-plus matrix powering in O(n 3 log n) time and the Dijkstra s Algorithm Last time we saw two methods to solve the all-pairs shortest path problem: Min-plus matrix powering in O(n 3 log n) time and the Floyd-Warshall algorithm in O(n 3 ) time. Neither of

More information

CSE 421 Greedy Alg: Union Find/Dijkstra s Alg

CSE 421 Greedy Alg: Union Find/Dijkstra s Alg CSE 1 Greedy Alg: Union Find/Dijkstra s Alg Shayan Oveis Gharan 1 Dijkstra s Algorithm Dijkstra(G, c, s) { d s 0 foreach (v V) d[v] //This is the key of node v foreach (v V) insert v onto a priority queue

More information

Minimum Spanning Tree

Minimum Spanning Tree Minimum Spanning Tree 1 Minimum Spanning Tree G=(V,E) is an undirected graph, where V is a set of nodes and E is a set of possible interconnections between pairs of nodes. For each edge (u,v) in E, we

More information

Data Structures Brett Bernstein

Data Structures Brett Bernstein Data Structures Brett Bernstein Final Review 1. Consider a binary tree of height k. (a) What is the maximum number of nodes? (b) What is the maximum number of leaves? (c) What is the minimum number of

More information

Unit #9: Graphs. CPSC 221: Algorithms and Data Structures. Will Evans 2012W1

Unit #9: Graphs. CPSC 221: Algorithms and Data Structures. Will Evans 2012W1 Unit #9: Graphs CPSC 1: Algorithms and Data Structures Will Evans 01W1 Unit Outline Topological Sort: Getting to Know Graphs with a Sort Graph ADT and Graph Representations Graph Terminology More Graph

More information

Minimum-Spanning-Tree problem. Minimum Spanning Trees (Forests) Minimum-Spanning-Tree problem

Minimum-Spanning-Tree problem. Minimum Spanning Trees (Forests) Minimum-Spanning-Tree problem Minimum Spanning Trees (Forests) Given an undirected graph G=(V,E) with each edge e having a weight w(e) : Find a subgraph T of G of minimum total weight s.t. every pair of vertices connected in G are

More information

Union Find and Greedy Algorithms. CSE 101: Design and Analysis of Algorithms Lecture 8

Union Find and Greedy Algorithms. CSE 101: Design and Analysis of Algorithms Lecture 8 Union Find and Greedy Algorithms CSE 101: Design and Analysis of Algorithms Lecture 8 CSE 101: Design and analysis of algorithms Union find Reading: Section 5.1 Greedy algorithms Reading: Kleinberg and

More information

Week 12: Minimum Spanning trees and Shortest Paths

Week 12: Minimum Spanning trees and Shortest Paths Agenda: Week 12: Minimum Spanning trees and Shortest Paths Kruskal s Algorithm Single-source shortest paths Dijkstra s algorithm for non-negatively weighted case Reading: Textbook : 61-7, 80-87, 9-601

More information

Minimum Spanning Trees

Minimum Spanning Trees Minimum Spanning Trees Problem A town has a set of houses and a set of roads. A road connects 2 and only 2 houses. A road connecting houses u and v has a repair cost w(u, v). Goal: Repair enough (and no

More information

Tutorial. Question There are no forward edges. 4. For each back edge u, v, we have 0 d[v] d[u].

Tutorial. Question There are no forward edges. 4. For each back edge u, v, we have 0 d[v] d[u]. Tutorial Question 1 A depth-first forest classifies the edges of a graph into tree, back, forward, and cross edges. A breadth-first tree can also be used to classify the edges reachable from the source

More information

Weighted Graph Algorithms Presented by Jason Yuan

Weighted Graph Algorithms Presented by Jason Yuan Weighted Graph Algorithms Presented by Jason Yuan Slides: Zachary Friggstad Programming Club Meeting Weighted Graphs struct Edge { int u, v ; int w e i g h t ; // can be a double } ; Edge ( int uu = 0,

More information

Last week: Breadth-First Search

Last week: Breadth-First Search 1 Last week: Breadth-First Search Set L i = [] for i=1,,n L 0 = {w}, where w is the start node For i = 0,, n-1: For u in L i : For each v which is a neighbor of u: If v isn t yet visited: - mark v as visited,

More information

Shortest path problems

Shortest 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 information

CSE 431/531: Analysis of Algorithms. Greedy Algorithms. Lecturer: Shi Li. Department of Computer Science and Engineering University at Buffalo

CSE 431/531: Analysis of Algorithms. Greedy Algorithms. Lecturer: Shi Li. Department of Computer Science and Engineering University at Buffalo CSE 431/531: Analysis of Algorithms Greedy Algorithms Lecturer: Shi Li Department of Computer Science and Engineering University at Buffalo Main Goal of Algorithm Design Design fast algorithms to solve

More information

Lecture 11: Analysis of Algorithms (CS ) 1

Lecture 11: Analysis of Algorithms (CS ) 1 Lecture 11: Analysis of Algorithms (CS583-002) 1 Amarda Shehu November 12, 2014 1 Some material adapted from Kevin Wayne s Algorithm Class @ Princeton 1 2 Dynamic Programming Approach Floyd-Warshall Shortest

More information

Spanning Trees. Lecture 20 CS2110 Spring 2015

Spanning Trees. Lecture 20 CS2110 Spring 2015 1 Spanning Trees Lecture 0 CS110 Spring 01 1 Undirected trees An undirected graph is a tree if there is exactly one simple path between any pair of vertices Root of tree? It doesn t matter choose any vertex

More information

Exam 3 Practice Problems

Exam 3 Practice Problems Exam 3 Practice Problems HONOR CODE: You are allowed to work in groups on these problems, and also to talk to the TAs (the TAs have not seen these problems before and they do not know the solutions but

More information

Solving problems on graph algorithms

Solving problems on graph algorithms Solving problems on graph algorithms Workshop Organized by: ACM Unit, Indian Statistical Institute, Kolkata. Tutorial-3 Date: 06.07.2017 Let G = (V, E) be an undirected graph. For a vertex v V, G {v} is

More information

SPANNING TREES. Lecture 21 CS2110 Spring 2016

SPANNING TREES. Lecture 21 CS2110 Spring 2016 1 SPANNING TREES Lecture 1 CS110 Spring 016 Spanning trees What we do today: Calculating the shortest path in Dijkstra s algorithm Look at time complexity of shortest path Definitions Minimum spanning

More information

Improving network robustness

Improving network robustness Improving network robustness using distance-based graph measures Sander Jurgens November 10, 2014 dr. K.A. Buchin Eindhoven University of Technology Department of Math and Computer Science dr. D.T.H. Worm

More information

10/31/18. About A6, Prelim 2. Spanning Trees, greedy algorithms. Facts about trees. Undirected trees

10/31/18. About A6, Prelim 2. Spanning Trees, greedy algorithms. Facts about trees. Undirected trees //8 About A, Prelim Spanning Trees, greedy algorithms Lecture CS Fall 8 Prelim : Thursday, November. Visit exams page of course website and read carefully to find out when you take it (: or 7:) and what

More information

Spanning Trees, greedy algorithms. Lecture 20 CS2110 Fall 2018

Spanning Trees, greedy algorithms. Lecture 20 CS2110 Fall 2018 1 Spanning Trees, greedy algorithms Lecture 20 CS2110 Fall 2018 1 About A6, Prelim 2 Prelim 2: Thursday, 15 November. Visit exams page of course website and read carefully to find out when you take it

More information

Math 15 - Spring Homework 5.2 Solutions

Math 15 - Spring Homework 5.2 Solutions Math 15 - Spring 2017 - Homework 5.2 Solutions 1. (5.2 # 14 (not assigned)) Use Prim s algorithm to construct a minimal spanning tree for the following network. Draw the minimal tree and compute its total

More information

Scribe from 2014/2015: Jessica Su, Hieu Pham Date: October 6, 2016 Editor: Jimmy Wu

Scribe from 2014/2015: Jessica Su, Hieu Pham Date: October 6, 2016 Editor: Jimmy Wu CS 267 Lecture 3 Shortest paths, graph diameter Scribe from 2014/2015: Jessica Su, Hieu Pham Date: October 6, 2016 Editor: Jimmy Wu Today we will talk about algorithms for finding shortest paths in a graph.

More information

Minimum-Cost Spanning Tree. Example

Minimum-Cost Spanning Tree. Example Minimum-Cost Spanning Tree weighted connected undirected graph spanning tree cost of spanning tree is sum of edge costs find spanning tree that has minimum cost Example 2 4 12 6 3 Network has 10 edges.

More information

Example. Minimum-Cost Spanning Tree. Edge Selection Greedy Strategies. Edge Selection Greedy Strategies

Example. Minimum-Cost Spanning Tree. Edge Selection Greedy Strategies. Edge Selection Greedy Strategies Minimum-Cost Spanning Tree weighted connected undirected graph spanning tree cost of spanning tree is sum of edge costs find spanning tree that has minimum cost Example 2 4 12 6 3 Network has 10 edges.

More information

Homework Assignment #3 Graph

Homework Assignment #3 Graph CISC 4080 Computer Algorithms Spring, 2019 Homework Assignment #3 Graph Some of the problems are adapted from problems in the book Introduction to Algorithms by Cormen, Leiserson and Rivest, and some are

More information

Department of Computer Science and Engineering Analysis and Design of Algorithm (CS-4004) Subject Notes

Department of Computer Science and Engineering Analysis and Design of Algorithm (CS-4004) Subject Notes Page no: Department of Computer Science and Engineering Analysis and Design of Algorithm (CS-00) Subject Notes Unit- Greedy Technique. Introduction: Greedy is the most straight forward design technique.

More information

CS 170 Second Midterm ANSWERS 7 April NAME (1 pt): SID (1 pt): TA (1 pt): Name of Neighbor to your left (1 pt):

CS 170 Second Midterm ANSWERS 7 April NAME (1 pt): SID (1 pt): TA (1 pt): Name of Neighbor to your left (1 pt): CS 170 Second Midterm ANSWERS 7 April 2010 NAME (1 pt): SID (1 pt): TA (1 pt): Name of Neighbor to your left (1 pt): Name of Neighbor to your right (1 pt): Instructions: This is a closed book, closed calculator,

More information

managing an evolving set of connected components implementing a Union-Find data structure implementing Kruskal s algorithm

managing an evolving set of connected components implementing a Union-Find data structure implementing Kruskal s algorithm Spanning Trees 1 Spanning Trees the minimum spanning tree problem three greedy algorithms analysis of the algorithms 2 The Union-Find Data Structure managing an evolving set of connected components implementing

More information

Graphs. Data Structures and Algorithms CSE 373 SU 18 BEN JONES 1

Graphs. Data Structures and Algorithms CSE 373 SU 18 BEN JONES 1 Graphs Data Structures and Algorithms CSE 373 SU 18 BEN JONES 1 Warmup Discuss with your neighbors: Come up with as many kinds of relational data as you can (data that can be represented with a graph).

More information

Spanning Trees, greedy algorithms. Lecture 22 CS2110 Fall 2017

Spanning Trees, greedy algorithms. Lecture 22 CS2110 Fall 2017 1 Spanning Trees, greedy algorithms Lecture 22 CS2110 Fall 2017 1 We demo A8 Your space ship is on earth, and you hear a distress signal from a distance Planet X. Your job: 1. Rescue stage: Fly your ship

More information

Algorithm Analysis Graph algorithm. Chung-Ang University, Jaesung Lee

Algorithm Analysis Graph algorithm. Chung-Ang University, Jaesung Lee Algorithm Analysis Graph algorithm Chung-Ang University, Jaesung Lee Basic definitions Graph = (, ) where is a set of vertices and is a set of edges Directed graph = where consists of ordered pairs

More information

L9: Hierarchical Clustering

L9: Hierarchical Clustering L9: Hierarchical Clustering This marks the beginning of the clustering section. The basic idea is to take a set X of items and somehow partition X into subsets, so each subset has similar items. Obviously,

More information

DHANALAKSHMI 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 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 information

UNIT 3. Greedy Method. Design and Analysis of Algorithms GENERAL METHOD

UNIT 3. Greedy Method. Design and Analysis of Algorithms GENERAL METHOD UNIT 3 Greedy Method GENERAL METHOD Greedy is the most straight forward design technique. Most of the problems have n inputs and require us to obtain a subset that satisfies some constraints. Any subset

More information

Minimum Spanning Trees

Minimum Spanning Trees CS124 Lecture 5 Spring 2011 Minimum Spanning Trees A tree is an undirected graph which is connected and acyclic. It is easy to show that if graph G(V,E) that satisfies any two of the following properties

More information

Graph Contraction. Graph Contraction CSE341T/CSE549T 10/20/2014. Lecture 14

Graph Contraction. Graph Contraction CSE341T/CSE549T 10/20/2014. Lecture 14 CSE341T/CSE549T 10/20/2014 Lecture 14 Graph Contraction Graph Contraction So far we have mostly talking about standard techniques for solving problems on graphs that were developed in the context of sequential

More information

2.1 Greedy Algorithms. 2.2 Minimum Spanning Trees. CS125 Lecture 2 Fall 2016

2.1 Greedy Algorithms. 2.2 Minimum Spanning Trees. CS125 Lecture 2 Fall 2016 CS125 Lecture 2 Fall 2016 2.1 Greedy Algorithms We will start talking about methods high-level plans for constructing algorithms. One of the simplest is just to have your algorithm be greedy. Being greedy,

More information

Lecture 6: Linear Programming for Sparsest Cut

Lecture 6: Linear Programming for Sparsest Cut Lecture 6: Linear Programming for Sparsest Cut Sparsest Cut and SOS The SOS hierarchy captures the algorithms for sparsest cut, but they were discovered directly without thinking about SOS (and this is

More information

Outline. Graphs. Divide and Conquer.

Outline. Graphs. Divide and Conquer. GRAPHS COMP 321 McGill University These slides are mainly compiled from the following resources. - Professor Jaehyun Park slides CS 97SI - Top-coder tutorials. - Programming Challenges books. Outline Graphs.

More information

We have already seen the transportation problem and the assignment problem. Let us take the transportation problem, first.

We have already seen the transportation problem and the assignment problem. Let us take the transportation problem, first. Advanced Operations Research Prof. G. Srinivasan Department of Management Studies Indian Institute of Technology, Madras Lecture 19 Network Models In this lecture, we will discuss network models. (Refer

More information

MST & Shortest Path -Prim s -Djikstra s

MST & Shortest Path -Prim s -Djikstra s MST & Shortest Path -Prim s -Djikstra s PRIM s - Minimum Spanning Tree - A spanning tree of a graph is a tree that has all the vertices of the graph connected by some edges. - A graph can have one or more

More information

Parallel Pointers: Graphs

Parallel Pointers: Graphs Parallel Pointers: Graphs Breadth first Search (BFS) 101 Given a vertex S, what is the distance of all the other vertices from S? Why would this be useful? To find the fastest route through a network.

More information

Lecture 5: Graph algorithms 1

Lecture 5: Graph algorithms 1 DD2458, Problem Solving and Programming Under Pressure Lecture 5: Graph algorithms 1 Date: 2008-10-01 Scribe(s): Mikael Auno and Magnus Andermo Lecturer: Douglas Wikström This lecture presents some common

More information

Spanning Trees 4/19/17. Prelim 2, assignments. Undirected trees

Spanning Trees 4/19/17. Prelim 2, assignments. Undirected trees /9/7 Prelim, assignments Prelim is Tuesday. See the course webpage for details. Scope: up to but not including today s lecture. See the review guide for details. Deadline for submitting conflicts has passed.

More information

Spanning Trees. Lecture 22 CS2110 Spring 2017

Spanning Trees. Lecture 22 CS2110 Spring 2017 1 Spanning Trees Lecture 22 CS2110 Spring 2017 1 Prelim 2, assignments Prelim 2 is Tuesday. See the course webpage for details. Scope: up to but not including today s lecture. See the review guide for

More information

Lecture 8 13 March, 2012

Lecture 8 13 March, 2012 6.851: Advanced Data Structures Spring 2012 Prof. Erik Demaine Lecture 8 13 March, 2012 1 From Last Lectures... In the previous lecture, we discussed the External Memory and Cache Oblivious memory models.

More information

Trees Rooted Trees Spanning trees and Shortest Paths. 12. Graphs and Trees 2. Aaron Tan November 2017

Trees Rooted Trees Spanning trees and Shortest Paths. 12. Graphs and Trees 2. Aaron Tan November 2017 12. Graphs and Trees 2 Aaron Tan 6 10 November 2017 1 10.5 Trees 2 Definition Definition Definition: Tree A graph is said to be circuit-free if, and only if, it has no circuits. A graph is called a tree

More information

Konigsberg Bridge Problem

Konigsberg Bridge Problem Graphs Konigsberg Bridge Problem c C d g A Kneiphof e D a B b f c A C d e g D a b f B Euler s Graph Degree of a vertex: the number of edges incident to it Euler showed that there is a walk starting at

More information

Announcements Problem Set 5 is out (today)!

Announcements Problem Set 5 is out (today)! CSC263 Week 10 Announcements Problem Set is out (today)! Due Tuesday (Dec 1) Minimum Spanning Trees The Graph of interest today A connected undirected weighted graph G = (V, E) with weights w(e) for each

More information

Algorithms for Minimum Spanning Trees

Algorithms for Minimum Spanning Trees Algorithms & Models of Computation CS/ECE, Fall Algorithms for Minimum Spanning Trees Lecture Thursday, November, Part I Algorithms for Minimum Spanning Tree Sariel Har-Peled (UIUC) CS Fall / 6 Sariel

More information

The ADT priority queue Orders its items by a priority value The first item removed is the one having the highest priority value

The ADT priority queue Orders its items by a priority value The first item removed is the one having the highest priority value The ADT priority queue Orders its items by a priority value The first item removed is the one having the highest priority value 1 Possible implementations Sorted linear implementations o Appropriate if

More information

CSE 373: Practice Final

CSE 373: Practice Final CSE 373: Practice Final 1 Short Answer a) Provide two orderings [0,1,2,3,4,5,6,7] that are worst-case for quick sort. Assume that you select the first element as the pivot. Explain why this is the worst-case.

More information

UNIT 5 GRAPH. Application of Graph Structure in real world:- Graph Terminologies:

UNIT 5 GRAPH. Application of Graph Structure in real world:- Graph Terminologies: UNIT 5 CSE 103 - Unit V- Graph GRAPH Graph is another important non-linear data structure. In tree Structure, there is a hierarchical relationship between, parent and children that is one-to-many relationship.

More information

CSE 100: B+ TREE, 2-3 TREE, NP- COMPLETNESS

CSE 100: B+ TREE, 2-3 TREE, NP- COMPLETNESS CSE 100: B+ TREE, 2-3 TREE, NP- COMPLETNESS Analyzing find in B-trees Since the B-tree is perfectly height-balanced, the worst case time cost for find is O(logN) Best case: If every internal node is completely

More information

Chapter 23. Minimum Spanning Trees

Chapter 23. Minimum Spanning Trees Chapter 23. Minimum Spanning Trees We are given a connected, weighted, undirected graph G = (V,E;w), where each edge (u,v) E has a non-negative weight (often called length) w(u,v). The Minimum Spanning

More information

Theory of Computing. Lecture 10 MAS 714 Hartmut Klauck

Theory of Computing. Lecture 10 MAS 714 Hartmut Klauck Theory of Computing Lecture 10 MAS 714 Hartmut Klauck Data structures: Union-Find We need to store a set of disjoint sets with the following operations: Make-Set(v): generate a set {v}. Name of the set

More information

Chapter 14 Section 3 - Slide 1

Chapter 14 Section 3 - Slide 1 AND Chapter 14 Section 3 - Slide 1 Chapter 14 Graph Theory Chapter 14 Section 3 - Slide WHAT YOU WILL LEARN Graphs, paths and circuits The Königsberg bridge problem Euler paths and Euler circuits Hamilton

More information

COMP 355 Advanced Algorithms

COMP 355 Advanced Algorithms COMP 355 Advanced Algorithms Algorithms for MSTs Sections 4.5 (KT) 1 Minimum Spanning Tree Minimum spanning tree. Given a connected graph G = (V, E) with realvalued edge weights c e, an MST is a subset

More information

Weighted Graphs and Greedy Algorithms

Weighted Graphs and Greedy Algorithms COMP 182 Algorithmic Thinking Weighted Graphs and Greedy Algorithms Luay Nakhleh Computer Science Rice University Reading Material Chapter 10, Section 6 Chapter 11, Sections 4, 5 Weighted Graphs In many

More information

22 Elementary Graph Algorithms. There are two standard ways to represent a

22 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 information

Design and Analysis of Algorithms

Design and Analysis of Algorithms CSE 1, Winter 201 Design and Analysis of Algorithms Lecture 7: Bellman-Ford, SPs in DAGs, PQs Class URL: http://vlsicad.ucsd.edu/courses/cse1-w1/ Lec. Added after class Figure.: Single-Edge Extensions

More information

Solving Linear Recurrence Relations (8.2)

Solving Linear Recurrence Relations (8.2) EECS 203 Spring 2016 Lecture 18 Page 1 of 10 Review: Recurrence relations (Chapter 8) Last time we started in on recurrence relations. In computer science, one of the primary reasons we look at solving

More information

Minimum Spanning Trees

Minimum Spanning Trees CSMPS 2200 Fall Minimum Spanning Trees Carola Wenk Slides courtesy of Charles Leiserson with changes and additions by Carola Wenk 11/6/ CMPS 2200 Intro. to Algorithms 1 Minimum spanning trees Input: A

More information

Introduction to Algorithms I

Introduction to Algorithms I Summer School on Algorithms and Optimization Organized by: ACM Unit, ISI and IEEE CEDA. Tutorial II Date: 05.07.017 Introduction to Algorithms I (Q1) A binary tree is a rooted tree in which each node has

More information

CS 310: Memory Hierarchy and B-Trees

CS 310: Memory Hierarchy and B-Trees CS 310: Memory Hierarchy and B-Trees Chris Kauffman Week 14-1 Matrix Sum Given an M by N matrix X, sum its elements M rows, N columns Sum R given X, M, N sum = 0 for i=0 to M-1{ for j=0 to N-1 { sum +=

More information

CISC 1100: Structures of Computer Science

CISC 1100: Structures of Computer Science CISC 1100: Structures of Computer Science Chapter 8 Algorithms Gary M. Weiss Fordham University Department of Computer and Information Sciences Fall, 2010 What is an algorithm? There are many ways to define

More information

B-Trees and External Memory

B-Trees and External Memory Presentation for use with the textbook, Algorithm Design and Applications, by M. T. Goodrich and R. Tamassia, Wiley, 2015 and External Memory 1 1 (2, 4) Trees: Generalization of BSTs Each internal node

More information

DO NOT RE-DISTRIBUTE THIS SOLUTION FILE

DO NOT RE-DISTRIBUTE THIS SOLUTION FILE Professor Kindred Math 104, Graph Theory Homework 3 Solutions February 14, 2013 Introduction to Graph Theory, West Section 2.1: 37, 62 Section 2.2: 6, 7, 15 Section 2.3: 7, 10, 14 DO NOT RE-DISTRIBUTE

More information

Lecturers: Sanjam Garg and Prasad Raghavendra March 20, Midterm 2 Solutions

Lecturers: Sanjam Garg and Prasad Raghavendra March 20, Midterm 2 Solutions U.C. Berkeley CS70 : Algorithms Midterm 2 Solutions Lecturers: Sanjam Garg and Prasad aghavra March 20, 207 Midterm 2 Solutions. (0 points) True/False Clearly put your answers in the answer box in front

More information

CSCI 5454 Ramdomized Min Cut

CSCI 5454 Ramdomized Min Cut CSCI 5454 Ramdomized Min Cut Sean Wiese, Ramya Nair April 8, 013 1 Randomized Minimum Cut A classic problem in computer science is finding the minimum cut of an undirected graph. If we are presented with

More information

Local Algorithms for Sparse Spanning Graphs

Local Algorithms for Sparse Spanning Graphs Local Algorithms for Sparse Spanning Graphs Reut Levi Dana Ron Ronitt Rubinfeld Intro slides based on a talk given by Reut Levi Minimum Spanning Graph (Spanning Tree) Local Access to a Minimum Spanning

More information

Elementary Graph Algorithms: Summary. Algorithms. CmSc250 Intro to Algorithms

Elementary Graph Algorithms: Summary. Algorithms. CmSc250 Intro to Algorithms Elementary Graph Algorithms: Summary CmSc250 Intro to Algorithms Definition: A graph is a collection (nonempty set) of vertices and edges A path from vertex x to vertex y : a list of vertices in which

More information

Problem Score Maximum MC 34 (25/17) = 50 Total 100

Problem Score Maximum MC 34 (25/17) = 50 Total 100 Stony Brook University Midterm 2 CSE 373 Analysis of Algorithms November 22, 2016 Midterm Exam Name: ID #: Signature: Circle one: GRAD / UNDERGRAD INSTRUCTIONS: This is a closed book, closed mouth exam.

More information

Speeding up Queries in a Leaf Image Database

Speeding up Queries in a Leaf Image Database 1 Speeding up Queries in a Leaf Image Database Daozheng Chen May 10, 2007 Abstract We have an Electronic Field Guide which contains an image database with thousands of leaf images. We have a system which

More information

Inital Starting Point Analysis for K-Means Clustering: A Case Study

Inital Starting Point Analysis for K-Means Clustering: A Case Study lemson University TigerPrints Publications School of omputing 3-26 Inital Starting Point Analysis for K-Means lustering: A ase Study Amy Apon lemson University, aapon@clemson.edu Frank Robinson Vanderbilt

More information