1 / 99

Chapter 4: Basic Graph Algorithms and Computational Complexity

Chapter 4: Basic Graph Algorithms and Computational Complexity. Massoud Pedram Dept. of EE University of Southern California . Outline. Analysis of Algorithms Graph Algorithms Dynamic Programming Mathematical Programming Stochastic Search Greedy Algorithms Divide and Conquer

lexiss
Download Presentation

Chapter 4: Basic Graph Algorithms and Computational Complexity

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 4: Basic Graph Algorithms and Computational Complexity Massoud Pedram Dept. of EE University of Southern California

  2. Outline • Analysis of Algorithms • Graph Algorithms • Dynamic Programming • Mathematical Programming • Stochastic Search • Greedy Algorithms • Divide and Conquer • Floorplanning

  3. Analysis of Algorithms • Big-O notation • O(f(n)) means that as n  , the execution time t is at most cf(n) for some constant c • Small-o notation • o(f(n)) means that as n  , the execution time t is at least cf(n) for some constant c • Theta notation • (f(n)) means that as n  , the execution time t is at most c1f(n) and at least c2f(n)for some constants c1and c2 where n = input size

  4. Big-O Notation • Express the execution time as a function of the input size n. Since only the growth rate matters, we can ignore the multiplicative constants and the lower order terms, e.g., • 3n2+6n+2.7 is O(n2) • n1.1 + 10000000000n is O(n1.1) • n1.1 is O(n1.1)

  5. 800 f(n)=n2 600 Run time 400 f(n)=10n 200 0 n 10 20 25 Effect of Multiplicative Constant

  6. Growth Rate of Some Functions O(log n), O(log2n), O(n0.5), O(n), O(n log n), O(n1.5), O(n log2n), O(n2), O(n3), O(n4) O(nlog n), O(2n), O(3n), O(4n), O(nn), O(n!) Polynomial Functions Exponential Functions

  7. n 2n 1ms x 2n 10 103 0.001 s 20 106 1 s 30 109 16.7 mins 40 1012 11.6 days 50 1015 31.7 years 60 1018 31710 years Exponential Functions • Exponential functions increase rapidly, e.g., 2n will double whenever n is increased by 1

  8. NP-Complete • The class NP-Complete is a set of problems that, we believe, has no polynomial time algorithms • Therefore, they are hard problems • If a problem is NP-complete, there is no hope to solve it efficiently

  9. Solution Type for NP-Complete Problems • Exponential time algorithms • Special case algorithms • Approximation algorithms • Heuristic algorithms

  10. Graph Algorithms

  11. A B D C A B D C Dual Graph G Graph G Basic Graph Definitions • A graph G(V,E) is a collection of vertices in V connected by a set of edges E • Dual of a graph G is obtained by replacing each face of G with one vertex and connecting two such vertices by an edge if the two corresponding faces share a common edge in G

  12. Types of Graph Commonly Used in VLSI CAD • Interval graphs • Permutation graphs • Comparability graphs • Vertical and horizontal constraint graphs • Neighborhood graphs and rectangular dualization

  13. Interval Graphs A B C E D G F A B C E F G D V = Set of intervals E = {(vi,vj) | viand vjintersect}

  14. Permutation Graphs A B C D E B E D A C A E B D C V = Set of lines E = {(vi,vj) | viand vjintersect}

  15. ? Orientable graph Non-orientable graph Comparability Graphs • Orientable Property: Each edge can be assigned a one-way direction in such a way that the resulting graph G(V,F) satisfies the following property: • An undirected graph which is transitively orientable is called a comparability graph

  16. A wA B wB wA D C wC Horizontal Constraint Graphs C D A B Weighted directed graph: V = Set of modules E = {(vi,vj) | vjon the right of vi} weight(vi, vj) = width of module vi

  17. A B hB hA D C Vertical Constraint Graphs C D A B Weighted directed graph: V = Set of modules E = {(vi,vj) | vjabove vi} weight(vi, vj) = height of module vi

  18. A B D C Neighborhood Graphs C D A B V = Set of modules E = {(vi,vj) | vjand vishare an edge}

  19. A B A C B D D C Rectangular Dualization Rectangular dualization does the inverse operation of the neighborhood graph construction Each rectangle represents a vertex viand vjshare an edge exactly if e(vi,vj) exists Some graphs have no rectangular duals

  20. Basic Graph Algorithms Commonly Used in VLSI CAD • Minimum Spanning Tree (MST) Problems • Steiner Minimum Tree (SMT) Problems • Rectilinear SMT Problems • Partitioning Problems • Network Flow Problems

  21. Minimum Spanning Tree (MST) • Problem: Given a connected undirected weighted graph G(V,E), construct a minimum weighted tree T connecting all vertices in V • Note: A graph is connected exactly if there is at least one path for any pair of vertices

  22. Minimum Spanning Tree (MST) • Kruskal’s algorithm: • O(m log n) • Prim’s algorithm : • O(m log n) • Can be improved to O(n log n) • A greedy algorithm • Note: m = no. of edges; n = no. of vertices

  23. Kruskal’s Algorithm • Sort the edges • T =  • Consider the edges in ascending order of their weights until T contains n-1 edges: • Add an edge e to T exactly if adding e to T does not create any cycle in T

  24. e e Kruskal’s Algorithm Example

  25. e e Kruskal’s Algorithm Example (Cont’d)

  26. Kruskal’s Algorithm Example (Cont’d)

  27. Prim’s Algorithm • T =  • S = {v} for an arbitrary vertex v • Repeat until S contains all the vertices: • Add the lightest edge e(v1,v2) to T where v1S and v2(V-S). Add v2 to S

  28. Prim’s algorithm Example

  29. Prim’s algorithm Example (Cont’d)

  30. Steiner Minimum Tree (SMT) • Problem: Given an undirected weighted graph G(V,E) and a demand set D  V, find a minimum cost tree T which spans a set of vertices V’V such that DV’ • Elements of V’-D, which have a degree larger than 2 in T, are called the Steiner points

  31. Steiner Minimum Tree (SMT) • When D = V, SMT = MST • When |D| = 2, SMT = Single Pair Shortest Path Problem • The SMT problem is NP-Complete

  32. Steiner point Demand point Rectilinear Steiner Tree (RST) • A Steiner tree whose edges are constrained to be vertical or horizontal

  33. Rectilinear Steiner Minimum Tree (RSMT) • Similar to the SMT problem, except that the tree T is a minimum cost rectilinear Steiner tree • This problem is NP-Complete but we can get an approximate solution to this problem by making use of the MST

  34. There can be many solutions or a better one MST Approximate Solution to RSMT • Construct a MST T • Obtain a RST T’ from T by connecting the vertices in T using vertical and horizontal edges

  35. Approximate Solution to RSMT • It is proved that: • WMST 1.5 WRSMT • Let W be the weight of the Steiner tree obtained by this method, i.e., by “rectilinearizing” the MST • What is the smallest b such that: • W  bWMST

  36. Other Graph Problems • Minimum Clique Covering Problem • Maximum Independent Set Problem • Minimum Coloring Problem • Maximum Clique Problem • Network Flow Problem

  37. Minimum Clique Covering • A clique of a graph G(V,E) is a set of vertices V’ V such that every pair of vertices in V’ are joined by an edge • The clique cover number, k, of a graph G(V,E) is the minimum no. of cliques needed to cover all of the vertices of G • The problem of finding the clique cover number is NP-complete for general graphs

  38. Maximum Independent Set (MIS) • An independent set of a graph G(V,E) is a set of vertices V’ V such that no pair of vertices in V’ are joined by an edge • The MIS problem is to find the independence (stability) number, a, of a graph, i.e., the size of the largest independent set in the graph • This problem is NP-complete for general graphs • What is the relationship between the clique cover number and the independence number? Answer:

  39. Graph Problems in Interval Graphs • What is the meaning of a clique cover in an interval graph? • What is the meaning of a MIS in an interval graph? • The clique covering and MIS in an interval graph can be found in O(n log n) time where n is the no. of intervals. How? • Answer for MIS: • Sort the 2n points in ascending order • Scan list from left to right until encounter a right endpoint • Output the interval having this right endpoint as a member of MIS and delete all intervals containing this point • Repeat until done

  40. Minimum Chromatic Number • The chromatic number, c, of a graph G(V,E) is the minimum no. of colors needed to color the vertices such that every pair of vertices joined by an edge are colored differently • The problem of finding the chromatic number is NP-complete for general graphs

  41. Maximum Clique • The maximum clique problem is to find the clique number, w, of a graph, i.e., the size of the largest clique in the graph • This problem is NP-complete for general graphs • What is the relationship between the chromatic number and the clique number? Answer:

  42. Graph Problems in Interval Graphs (Cont’d) • What is the meaning of the chromatic number and the clique number in an interval graph? • The chromatic number and the clique number of an interval graph can be found in O(n log n) time. How? • Answer for maximum clique {simple O(n2) algorithm} • A = Sort intervals (I); • cliq=0; max-cliq=0; • for i=1 to 2n do • if A[i]=Left then cliq++; • if cliq > max-cliq then max-cliq=cliq; • else cliq--; • Return max-cliq;

  43. Perfect Graphs • A graph G(V,E) is called perfect of all of its induced sub-graphs satisfy the following two properties: • P1: • P2: • Interval graphs, permutation graphs and orientable graphs are examples of the perfect graphs; Cycle of odd length > 3 is not a perfect graph • The four key graph problems can be solved in polynomial time for the class of perfect graphs

  44. Partitioning Problem • Problem: Given an undirected graph G(V,E), partition V into two sets V1 and V2 of equal sizes such that the number of edges |E1| between V1 and V2 is minimized • E1 is called the cut

  45. Partitioning Problem • More general versions of this problem: • Specify the sizes of V1 and V2 • Partition V into k sets where k  2 • All these problems are NP-complete

  46. Network Flow Problem • Problem: Given a weighted directed graph G(V,E). One vertex sVis designated as the source and one vertex tV as the sink. Find the maximum flow from s to t such that the flow along each edge does not exceed the capacity (weight) of the edge

  47. 3 a b 10 7 4 5 6 s 5 t 7 10 c d 2 Network Flow Problem • For example: • What is the maximum flow in this network? (see next slide) • Network flow problem can be solved in polynomial time

  48. 3/3 a b 9/10 3/7 5 4/4 6 s t 2/5 7 6/10 c d 2/2 Network Flow Problem • The maximum flow is 9 • A well known theorem: • Maximum Flow = Minimum Cut

  49. 3 a b 7 10 4 5 6 s t 5 7 10 c d 2 Network Flow Problem • The minimum cut is 9 • Notice that we only count the edges going from s to t

  50. Network Flow Problem • Unfortunately, we cannot use this network flow method to solve the partitioning problem. Why?

More Related