NP-Completeness Theory for Graph Algorithms in CSCE-411

csce 411 n.w
1 / 44
Embed
Share

Delve into NP-completeness theory in CSCE-411, focusing on avoiding complex problems. Projects involve implementing algorithms for finding shortest and longest paths in weighted graphs. Explore assigned tasks, including Dijkstra's algorithm, in solving these computational challenges.

  • NP-Completeness
  • CSCE-411
  • Graph Algorithms
  • Dijkstras Algorithm
  • Weighted Graphs

Uploaded on | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. CSCE-411 Design and Analysis of Algorithms Spring 2025 Instructor: Jianer Chen Office: PETR 428 Phone: 845-4259 Email: chen@cse.tamu.edu Notes 33: NP-completeness Theory

  2. NP-Completeness Theory Try to tell you how to avoid solving a problem (because it is too hard).

  3. NP-Completeness Theory Try to tell you how to avoid solving a problem (because it is too hard). Project A. Write a useable program (algorithm) that, given a weighted graph G and two vertices s and t, finds a shortest path from s to t. Project B. Write a useable program (algorithm) that, given a weighted graph G and two vertices s and t, finds a longest simple path from s to t.

  4. NP-Completeness Theory Try to tell you how to avoid solving a problem (because it is too hard). Project A. Write a useable program (algorithm) that, given a weighted graph G and two vertices s and t, finds a shortest path from s to t. Assigned to your colleague Project B. Write a useable program (algorithm) that, given a weighted graph G and two vertices s and t, finds a longest simple path from s to t. Assigned to you

  5. NP-Completeness Theory Try to tell you how to avoid solving a problem (because it is too hard). Project A. Write a useable program (algorithm) that, given a weighted graph G and two vertices s and t, finds a shortest path from s to t. Assigned to your colleague: Dijkstra, Bellman-Ford, Floyd-Warshall, Johnson, . Project B. Write a useable program (algorithm) that, given a weighted graph G and two vertices s and t, finds a longest simple path from s to t. Assigned to you

  6. NP-Completeness Theory Try to tell you how to avoid solving a problem (because it is too hard). Project A. Write a useable program (algorithm) that, given a weighted graph G and two vertices s and t, finds a shortest path from s to t. Assigned to your colleague: Dijkstra, Bellman-Ford, Floyd-Warshall, Johnson, . Project B. Write a useable program (algorithm) that, given a weighted graph G and two vertices s and t, finds a longest simple path from s to t. Assigned to you: Dijkstra?

  7. NP-Completeness Theory Try to tell you how to avoid solving a problem (because it is too hard). Project A. Write a useable program (algorithm) that, given a weighted graph G and two vertices s and t, finds a shortest path from s to t. Assigned to your colleague: Dijkstra, Bellman-Ford, Floyd-Warshall, Johnson, . Project B. Write a useable program (algorithm) that, given a weighted graph G and two vertices s and t, finds a longest simple path from s to t. Assigned to you: Dijkstra,

  8. NP-Completeness Theory Try to tell you how to avoid solving a problem (because it is too hard). Project A. Write a useable program (algorithm) that, given a weighted graph G and two vertices s and t, finds a shortest path from s to t. Assigned to your colleague: Dijkstra, Bellman-Ford, Floyd-Warshall, Johnson, . Project B. Write a useable program (algorithm) that, given a weighted graph G and two vertices s and t, finds a longest simple path from s to t. Assigned to you: Dijkstra, Bellman-Ford?

  9. NP-Completeness Theory Try to tell you how to avoid solving a problem (because it is too hard). Project A. Write a useable program (algorithm) that, given a weighted graph G and two vertices s and t, finds a shortest path from s to t. Assigned to your colleague: Dijkstra, Bellman-Ford, Floyd-Warshall, Johnson, . Project B. Write a useable program (algorithm) that, given a weighted graph G and two vertices s and t, finds a longest simple path from s to t. Assigned to you: Dijkstra, Bellman-Ford,

  10. NP-Completeness Theory Try to tell you how to avoid solving a problem (because it is too hard). Project A. Write a useable program (algorithm) that, given a weighted graph G and two vertices s and t, finds a shortest path from s to t. Assigned to your colleague: Dijkstra, Bellman-Ford, Floyd-Warshall, Johnson, . Project B. Write a useable program (algorithm) that, given a weighted graph G and two vertices s and t, finds a longest simple path from s to t. Assigned to you: Dijkstra, Bellman-Ford, Floyd-Warshall?

  11. NP-Completeness Theory Try to tell you how to avoid solving a problem (because it is too hard). Project A. Write a useable program (algorithm) that, given a weighted graph G and two vertices s and t, finds a shortest path from s to t. Assigned to your colleague: Dijkstra, Bellman-Ford, Floyd-Warshall, Johnson, . Project B. Write a useable program (algorithm) that, given a weighted graph G and two vertices s and t, finds a longest simple path from s to t. Assigned to you: Dijkstra, Bellman-Ford, Floyd-Warshall,

  12. NP-Completeness Theory Try to tell you how to avoid solving a problem (because it is too hard). Project A. Write a useable program (algorithm) that, given a weighted graph G and two vertices s and t, finds a shortest path from s to t. Assigned to your colleague: Dijkstra, Bellman-Ford, Floyd-Warshall, Johnson, . Project B. Write a useable program (algorithm) that, given a weighted graph G and two vertices s and t, finds a longest simple path from s to t. Assigned to you: Dijkstra, Bellman-Ford, Floyd-Warshall, Johnson?

  13. NP-Completeness Theory Try to tell you how to avoid solving a problem (because it is too hard). Project A. Write a useable program (algorithm) that, given a weighted graph G and two vertices s and t, finds a shortest path from s to t. Assigned to your colleague: Dijkstra, Bellman-Ford, Floyd-Warshall, Johnson, . Project B. Write a useable program (algorithm) that, given a weighted graph G and two vertices s and t, finds a longest simple path from s to t. Assigned to you: Dijkstra, Bellman-Ford, Floyd-Warshall, Johnson, .

  14. NP-Completeness Theory Try to tell you how to avoid solving a problem (because it is too hard). Project A. Write a useable program (algorithm) that, given a weighted graph G and two vertices s and t, finds a shortest path from s to t. Assigned to your colleague: Dijkstra, Bellman-Ford, Floyd-Warshall, Johnson, . Project B. Write a useable program (algorithm) that, given a weighted graph G and two vertices s and t, finds a longest simple path from s to t. Assigned to you: Dijkstra, Bellman-Ford, Floyd-Warshall, Johnson, . XXXXXXXXXXXXXX

  15. NP-Completeness Theory Try to tell you how to avoid solving a problem (because it is too hard). Project A. Write a useable program (algorithm) that, given a weighted graph G and two vertices s and t, finds a shortest path from s to t. Assigned to your colleague: Dijkstra, Bellman-Ford, Floyd-Warshall, Johnson, . Project B. Write a useable program (algorithm) that, given a weighted graph G and two vertices s and t, finds a longest simple path from s to t. Assigned to you: Dijkstra, Bellman-Ford, Floyd-Warshall, Johnson, . XXXXXXXXXXXXXX

  16. NP-Completeness Theory What you will do next? Project B. Write a useable algorithm that, given a weighted graph G and two vertices s and t, finds a longest simple path from s to t. Assigned to you: Dijkstra, Bellman-Ford, Floyd-Warshall, Johnson, . XXXXXXXXXXXXXX

  17. NP-Completeness Theory What you will do next? Project B. Write a useable algorithm that, given a weighted graph G and two vertices s and t, finds a longest simple path from s to t. Assigned to you: Dijkstra, Bellman-Ford, Floyd-Warshall, Johnson, . XXXXXXXXXXXXXX Work harder

  18. NP-Completeness Theory What you will do next? Project B. Write a useable algorithm that, given a weighted graph G and two vertices s and t, finds a longest simple path from s to t. Assigned to you: Dijkstra, Bellman-Ford, Floyd-Warshall, Johnson, . XXXXXXXXXXXXXX Work harder Does not help I guarantee that you would not solve it.

  19. NP-Completeness Theory What you will do next? Project B. Write a useable algorithm that, given a weighted graph G and two vertices s and t, finds a longest simple path from s to t. Assigned to you: Dijkstra, Bellman-Ford, Floyd-Warshall, Johnson, . XXXXXXXXXXXXXX Work harder Does not help I guarantee that you would not solve it. Tell your boss the problem is difficult

  20. NP-Completeness Theory What you will do next? Project B. Write a useable algorithm that, given a weighted graph G and two vertices s and t, finds a longest simple path from s to t. Assigned to you: Dijkstra, Bellman-Ford, Floyd-Warshall, Johnson, . XXXXXXXXXXXXXX Work harder Does not help I guarantee that you would not solve it. Tell your boss the problem is difficult Your boss is not going to be convinced

  21. NP-Completeness Theory What you will do next? Project B. Write a useable algorithm that, given a weighted graph G and two vertices s and t, finds a longest simple path from s to t. Assigned to you: Dijkstra, Bellman-Ford, Floyd-Warshall, Johnson, . XXXXXXXXXXXXXX Work harder Does not help I guarantee that you would not solve it. Tell your boss the problem is difficult Your boss is not going to be convinced Tell your boss you are not as good as your colleague

  22. NP-Completeness Theory What you will do next? Project B. Write a useable algorithm that, given a weighted graph G and two vertices s and t, finds a longest simple path from s to t. Assigned to you: Dijkstra, Bellman-Ford, Floyd-Warshall, Johnson, . XXXXXXXXXXXXXX Work harder Does not help I guarantee that you would not solve it. Tell your boss the problem is difficult Your boss is not going to be convinced Tell your boss you are not as good as your colleague In fact, you are innocent:

  23. NP-Completeness Theory What you will do next? Project B. Write a useable algorithm that, given a weighted graph G and two vertices s and t, finds a longest simple path from s to t. Assigned to you: Dijkstra, Bellman-Ford, Floyd-Warshall, Johnson, . XXXXXXXXXXXXXX Work harder Does not help I guarantee that you would not solve it. Tell your boss the problem is difficult Your boss is not going to be convinced Tell your boss you are not as good as your colleague In fact, you are innocent: Nobody (in the world) can give a useable algorithm for this problem

  24. NP-Completeness Theory What you will do next? Project B. Write a useable algorithm that, given a weighted graph G and two vertices s and t, finds a longest simple path from s to t. Assigned to you: Dijkstra, Bellman-Ford, Floyd-Warshall, Johnson, . XXXXXXXXXXXXXX Work harder Does not help I guarantee that you would not solve it. Tell your boss the problem is difficult Your boss is not going to be convinced Tell your boss you are not as good as your colleague In fact, you are innocent: Nobody (in the world) can give a useable algorithm for this problem Nobody (in the world) can prove that the problem is difficult.

  25. NP-Completeness Theory Project B. Write a useable algorithm that, given a weighted graph G and two vertices s and t, finds a longest simple path from s to t. Nobody (in the world) can give a useable algorithm for the problem Nobody (in the world) can prove that the problem is difficult.

  26. NP-Completeness Theory Project B. Write a useable algorithm that, given a weighted graph G and two vertices s and t, finds a longest simple path from s to t. Nobody (in the world) can give a useable algorithm for the problem Nobody (in the world) can prove that the problem is difficult.

  27. NP-Completeness Theory Project B. Write a useable algorithm that, given a weighted graph G and two vertices s and t, finds a longest simple path from s to t. Nobody (in the world) can give a useable algorithm for the problem Nobody (in the world) can prove that the problem is difficult. What is a useable algorithm? an algorithm that is fast enough.

  28. NP-Completeness Theory Project B. Write a useable algorithm that, given a weighted graph G and two vertices s and t, finds a longest simple path from s to t. Nobody (in the world) can give a useable algorithm for the problem Nobody (in the world) can prove that the problem is difficult. What is a useable algorithm? an algorithm that is fast enough. A problem is feasible if it can be solved by a useable algorithm.

  29. NP-Completeness Theory Project B. Write a useable algorithm that, given a weighted graph G and two vertices s and t, finds a longest simple path from s to t. Nobody (in the world) can give a useable algorithm for the problem Nobody (in the world) can prove that the problem is difficult. What is a useable algorithm? an algorithm that is fast enough. A problem is feasible if it can be solved by a useable algorithm.

  30. NP-Completeness Theory Project B. Write a useable algorithm that, given a weighted graph G and two vertices s and t, finds a longest simple path from s to t. Nobody (in the world) can give a useable algorithm for the problem Nobody (in the world) can prove that the problem is difficult. What is a useable algorithm? an algorithm that is fast enough. A problem is feasible if it can be solved by a useable algorithm. What problem is difficult? A problem that is infeasible. i.e., a problem that has no useable algorithms.

  31. NP-Completeness Theory Project B. Write a useable algorithm that, given a weighted graph G and two vertices s and t, finds a longest simple path from s to t. Nobody (in the world) can give a useable algorithm for the problem Nobody (in the world) can prove that the problem is difficult. What is a useable algorithm? an algorithm that is fast enough. A problem is feasible if it can be solved by a useable algorithm. What problem is difficult? A problem that is infeasible. i.e., a problem that has no useable algorithms. But how can you know (prove) that a problem has no useable algorithms?

  32. NP-Completeness Theory Project B. Write a useable algorithm that, given a weighted graph G and two vertices s and t, finds a longest simple path from s to t. Nobody (in the world) can give a useable algorithm for the problem Nobody (in the world) can prove that the problem is difficult. What is a useable algorithm? an algorithm that is fast enough. A problem is feasible if it can be solved by a useable algorithm. What problem is difficult? A problem that is infeasible. i.e., a problem that has no useable algorithms. But how can you know (prove) that a problem has no useable algorithms? Nobody can.

  33. NP-Completeness Theory Project B. Write a useable algorithm that, given a weighted graph G and two vertices s and t, finds a longest simple path from s to t. Nobody (in the world) can give a useable algorithm for the problem Nobody (in the world) can prove that the problem is difficult. What is a useable algorithm? an algorithm that is fast enough. A problem is feasible if it can be solved by a useable algorithm. What problem is difficult? A problem that is infeasible. i.e., a problem that has no useable algorithms. But how can you know (prove) that a problem has no useable algorithms? Nobody can. But we have NP-completeness theory.

  34. NP-Completeness Theory Project B. Write a useable algorithm that, given a weighted graph G and two vertices s and t, finds a longest simple path from s to t. Nobody (in the world) can give a useable algorithm for the problem Nobody (in the world) can prove that the problem is difficult. What is a useable algorithm? an algorithm that is fast enough. A problem is feasible if it can be solved by a useable algorithm. What problem is difficult? A problem that is infeasible. i.e., a problem that has no useable algorithms. But how can you know (prove) that a problem has no useable algorithms? Nobody can. But we have NP-completeness theory. The theory developed a framework that enables to prove that the given problem belongs to a class of (over thousands) problems that are all equivalent, in the sense that if you find a useable algorithm for any single of these problems, then you have useable algorithms for all (> 2,000) problems in the class.

  35. NP-Completeness Theory Project B. Write a useable algorithm that, given a weighted graph G and two vertices s and t, finds a longest simple path from s to t. Nobody (in the world) can give a useable algorithm for the problem Nobody (in the world) can prove that the problem is difficult. What is a useable algorithm? an algorithm that is fast enough. A problem is feasible if it can be solved by a useable algorithm. What problem is difficult? A problem that is infeasible. i.e., a problem that has no useable algorithms. But how can you know (prove) that a problem has no useable algorithms? Nobody can. But we have NP-completeness theory. The theory developed a framework that enables to prove that the given problem belongs to a class of (over thousands) problems that are all equivalent, in the sense that if you find a useable algorithm for any single of these problems, then you have useable algorithms for all (> 2,000) problems in the class. Current Status: No one in the world (including the smartest ones) has been able to find a useable algorithm for any single of the problems in the class.

  36. NP-Completeness Theory Project B. Write a useable algorithm that, given a weighted graph G and two vertices s and t, finds a longest simple path from s to t. Nobody (in the world) can give a useable algorithm for the problem Nobody (in the world) can prove that the problem is difficult. What is a useable algorithm? an algorithm that is fast enough. A problem is feasible if it can be solved by a useable algorithm. What problem is difficult? A problem that is infeasible. i.e., a problem that has no useable algorithms. But how can you know (prove) that a problem has no useable algorithms? Nobody can. But we have NP-completeness theory. The theory developed a framework that enables to prove that the given problem belongs to a class of (over thousands) problems that are all equivalent, in the sense that if you find a useable algorithm for any single of these problems, then you have useable algorithms for all (> 2,000) problems in the class. Current Status: No one in the world (including the smartest ones) has been able to find a useable algorithm for any single of the problems in the class. Thus, if your problem belongs to this class, you probably want to consider quitting (hopeless, unless you are smarter than all smartest computer scientists in the world).

  37. NP-Completeness Theory If a problem Q can be solved in polynomial time, i.e., in time O(nc) for a constant c, then we consider Q feasible.

  38. NP-Completeness Theory If a problem Q can be solved in polynomial time, i.e., in time O(nc) for a constant c, then we consider Q feasible. Let P to be the class of all problems solvable in polynomial time.

  39. NP-Completeness Theory If a problem Q can be solved in polynomial time, i.e., in time O(nc) for a constant c, then we consider Q feasible. Let P to be the class of all problems solvable in polynomial time. Examples. All problems we have studied in this class are in P. Sorting: O(n log n) = O(n2) Longest Common Subsequence: O(n2) Many graph problems solvable based on DFS and BFS: O(m+n) = O(L) Single Source Shortest Path: Dijktra: O(n2) or O(m log n) = O(n3), Bellman-Ford: O(nm) = O(n3) All-Pairs Shortest Path: Floyd-Warshall: O(n3), Johnson: O(nm log n) = O(n4) Minimum Spanning Tree: O(n2) or O(m log n) = O(n3), Bipartite Graph Matching: O(nm) = O(n3),

  40. NP-Completeness Theory If a problem Q can be solved in polynomial time, i.e., in time O(nc) for a constant c, then we consider Q feasible. Let P to be the class of all problems solvable in polynomial time. Consider the following problems: Vertex Cover (VC). Given a graph G and an integer k, can we find a set C of k vertices in G such that every edge of G has at least one end in C?

  41. NP-Completeness Theory If a problem Q can be solved in polynomial time, i.e., in time O(nc) for a constant c, then we consider Q feasible. Let P to be the class of all problems solvable in polynomial time. Consider the following problems: Vertex Cover (VC). Given a graph G and an integer k, can we find a set C of k vertices in G such that every edge of G has at least one end in C? Independent Set (IS). Given a graph G and an integer k, can we find a set I of k vertices in G such that no two vertices in I are adjacent?

  42. NP-Completeness Theory If a problem Q can be solved in polynomial time, i.e., in time O(nc) for a constant c, then we consider Q feasible. Let P to be the class of all problems solvable in polynomial time. Consider the following problems: Vertex Cover (VC). Given a graph G and an integer k, can we find a set C of k vertices in G such that every edge of G has at least one end in C? Independent Set (IS). Given a graph G and an integer k, can we find a set I of k vertices in G such that no two vertices in I are adjacent? Satisfiability (SAT). Given a CNF formula F = F(x1, x2, , xn), is there an assignment to x1, x2, , xn such that F = true?

  43. NP-Completeness Theory If a problem Q can be solved in polynomial time, i.e., in time O(nc) for a constant c, then we consider Q feasible. Let P to be the class of all problems solvable in polynomial time. Consider the following problems: Vertex Cover (VC). Given a graph G and an integer k, can we find a set C of k vertices in G such that every edge of G has at least one end in C? Independent Set (IS). Given a graph G and an integer k, can we find a set I of k vertices in G such that no two vertices in I are adjacent? Satisfiability (SAT). Given a CNF formula F = F(x1, x2, , xn), is there an assignment to x1, x2, , xn such that F = true? Partition. Given a set S = {a1, a2, , an} of n integers, is there a way to partition S into S1 and S2 such that S1 and S2 have the same sum?

  44. NP-Completeness Theory If a problem Q can be solved in polynomial time, i.e., in time O(nc) for a constant c, then we consider Q feasible. Let P to be the class of all problems solvable in polynomial time. Consider the following problems: Vertex Cover (VC). Given a graph G and an integer k, can we find a set C of k vertices in G such that every edge of G has at least one end in C? Independent Set (IS). Given a graph G and an integer k, can we find a set I of k vertices in G such that no two vertices in I are adjacent? Satisfiability (SAT). Given a CNF formula F = F(x1, x2, , xn), is there an assignment to x1, x2, , xn such that F = true? Partition. Given a set S = {a1, a2, , an} of n integers, is there a way to partition S into S1 and S2 such that S1 and S2 have the same sum? These problems have wide applications in practice, but no one knows how to solve any of them efficiently (i.e., are they in P ?)

Related


More Related Content