1 / 25

Lecture 13: Shortest Path and Graph Coloring

Lecture 13: Shortest Path and Graph Coloring. Shortest Path Problems Graph Coloring. 13.1. Shortest Path Problems. A weighted graph : Is a graph in which a number called the weight is assigned to each edge. The weight of a path : Is the sum of weights of the edges in the path.

gayle
Download Presentation

Lecture 13: Shortest Path and Graph Coloring

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. Lecture 13: Shortest Path and Graph Coloring • Shortest Path Problems • Graph Coloring MACM101 Discrete Mathematics I

  2. 13.1. Shortest Path Problems • A weighted graph: • Is a graph in which a number called the weight is assigned to each edge. • The weight of a path: • Is the sum of weights of the edges in the path. • The shortest path from u to v: • Is the path of the smallest weight between the two vertices. • The weight of that path is called the distance between them. MACM101 Discrete Mathematics I

  3. 13.1. Shortest Path Problems • Examples: • Weight of the edge on A and B is 3. • Weight of the path A, C, D, F is 4 + 2 + 5 = 11. • The shortest path between A and D is A, B, D. • The distance between A and D is 4. MACM101 Discrete Mathematics I

  4. 13.1. Shortest Path Problems • Examples: • The weight can be mileage, fares, response time, etc. MACM101 Discrete Mathematics I

  5. 13.1. Shortest Path Problems • Rationale • Given shortest path Pa-b from vertex a to b, and Pa-b passes vertex c • Path Pa-c (a subpath of Pa-b) is a shortest path from vertex a to c • Length of Pa-c <= Length of Pa-b MACM101 Discrete Mathematics I

  6. 13.1. Shortest Path Problems • Dijkstra’s Algorithm: Dijkstra (1930-2002) • Is a popular algorithm for finding shortest path. • Applications: Internet routing. MACM101 Discrete Mathematics I

  7. 13.1. Shortest Path Problems • Examples: • Use Dijkstra’s algorithm to find the length of the shortest path between the vertices a and z in the following weighted graph. • Solution: • At each iteration of the algorithm, the vertices of the set S is circled. The algorithm terminates when z is circled. MACM101 Discrete Mathematics I

  8. 13 (a, c, b, d, e) 13.1. Shortest Path Problems MACM101 Discrete Mathematics I

  9. 13.1. Shortest Path Problems • Question: • What about longest path ? MACM101 Discrete Mathematics I

  10. 13.1. Shortest Path Problems • Question: • What about negative weight ? MACM101 Discrete Mathematics I

  11. 13.1. Shortest Path Problems • Question: • In the algorithm, weight is additive, i.e., min w1+w2+w3… • How about multiplicative, i.e., min w1*w2*w3… MACM101 Discrete Mathematics I

  12. 13.1. Shortest Path Problems • Question: • In the algorithm, weight is additive, i.e., min w1+w2+w3… • How about multiplicative, i.e., min w1*w2*w3… • Solution: • Min w1*w2*w3… is equivalent to min (log w1*w2*w3…) MACM101 Discrete Mathematics I

  13. MACM101 Discrete Mathematics I

  14. MACM101 Discrete Mathematics I

  15. (E) (D) (A) (C) (B) 13.1. Shortest Path Problems • Important shortest path problem: • The traveling salesman problem. • A traveling salesman wants to visit each of n cities exactly once and return to his starting point. • In which order should he visit these cities to travel the minimum total distance? MACM101 Discrete Mathematics I

  16. 13.1. Shortest Path Problems • Solution: • Find all possible Hamilton circuits. • Assume that the salesman starts in Detroit. • Then we need to examine (n-1)!/2 different circuits. • Calculate the length of each circuit. • Select one with minimum total length. • A-B-C-D-E-A (or its reverse): 458 km. MACM101 Discrete Mathematics I

  17. 13.2. Graph Coloring • A coloring of a graph: • Is the assignment of a color to each vertex of the graph so that adjacent vertices have different colors. • For most graphs, we can use fewer colors than the number of vertices in the graph • The chromatic number of a graph: • Is the least number of colors needed for coloring the graph. MACM101 Discrete Mathematics I

  18. 13.2. Graph Coloring • Examples: • When a cycle Cn has an even number of vertices, it can be colored using 2 colors. • When a cycle Cn has an odd number of vertices, it can be colored using 3 colors. MACM101 Discrete Mathematics I

  19. 13.2. Graph Coloring • Examples: • Coloring for the complete graph Kn – • How many ? MACM101 Discrete Mathematics I

  20. 13.2. Graph Coloring • Examples: • The complete graph Kn can be colored with n colors. • No smaller number of colors is possible since every two vertices of this graph are adjacent. MACM101 Discrete Mathematics I

  21. 13.2. Graph Coloring • Examples: • The complete bipartite graph Km,n can be colored with 2 colors. • i.e. color the set of m vertices with one color and the set of n vertices with a second color. • e.g. A coloring of K3,4. MACM101 Discrete Mathematics I

  22. 13.2. Graph Coloring • The 4-color problem Chromatic number of a map (planar graph) ≤ 4 • 1850 – asked by a De Morgan’s student • 1976 – proved by K. Appel and W. Haken using a computer MACM101 Discrete Mathematics I

  23. 13.2. Graph Coloring • Applications of graph coloring: • Scheduling final exams. • How can the final exams can be scheduled so that no student has two exams at the same time? • Solution: • Use a graph model with vertices representing courses and with an edge between two vertices if there is a student taking both courses. • Each time slot of a final exam is represented by a different color. MACM101 Discrete Mathematics I

  24. 13.2. Graph Coloring • Solution (continued): • Suppose there are 7 finals with common students in courses {(1,2), (1,3), … } as represented by the graph. So, we need four color or time slots. MACM101 Discrete Mathematics I

  25. 13.3. Further Readings • Shortest Path Problems : Section 8.6. • Graph Coloring : Section 8.8. MACM101 Discrete Mathematics I

More Related