NP-Completeness. The classical reference is Computers and Intractability A guide to the theory of NP-Completeness Michael Garey and David Johnson W H Freeman, 1979. 1. Tractability. Nearly all problems discussed so far can be solved by algorithms with worst-case have time complexity of the form O(n^k), for fixed k. Typically, k is small, say, 2, 3. Examples include shortest paths, minimum spanning trees, sorting, LCS, matrix chain multiplication etc. These algorithms are "efficient" because their running time grows as a polynomial function of the input size. Problems solvable in times of the form O(n^k) are called polynomially-solvable, or *tractable*. We use P to denote this class of problems. 2. To better appreciate such efficient algorithms, consider the alternative. In all these problems, we are searching for a solution (path, tree, subsequence, sorted order) from among an exponential size list of possibilities. A graph will typically contain exponentially many paths, and trees; a sequence will have exponentially many subsequences; number of matrix multiplication orders is also exponential. All of these problem could in principle be solved by checking through all the possible solutions, and finding the best. By those solutions will in practice be useless. The algorithms and techniques that led the efficient shortest path, MST, LCS algorithms are among the most notable successes of our quest for computational breakthroughs that defeat the specter of exponentiality. But now it is time to meet our most humbling failure in this quest: look at search problems where we have failed to find efficient algorithms, and it appears no such method may be possible! 3. Problems that require exponential or worse time are called *intractable*, thus associating the label "tractable" with polynomial-time solvability. Why do we define tractability as polynomial time solvability? Several reasons: a. Universality: polynomial solvability holds across a wide spectrum of computational models: Turing machines, random access machines, most modern programming languages. b. Polynomial functions are closed under composition: if an algorithm calls another polynomial subroutine, it remains in the class P. c. Polynomial time is a good proxy for practically feasible: as the problem size grows, the running time worsens, but smoothly (polynomially) not abruptly the way exponential explosion occurs. d. Problem structure: Achieving polynomial time inevitably entails discovering some special structure in the problem that allows one to find the optimum without enumerating all possibilities. 4. NP-COMPLETE is a special class of intractable problems. This class contains a very diverse set of problems, with the following intriguing properties: a. we only know how to solve these problems in exponential time e.g. O(2^O(n^k)). b. if we could solve ANY NP-Complete problem in polynomial time, then we could solve ALL NP-Complete problems in poly time. NP = Non-deterministic Polynomial Time. Picture of P, NP, NPC class hierarchy. 5. Reasons for studying NP-Completeness. Practical: if we recognize problem is NPC, then we 3 choices: a. be prepared for any algorithm to take exp time; b. settle for an approximate solution, instead of optimal. c. alter the problem, constrain it, so it becomes in P. Philosophical: P = NP? is the most famous computer science open problem. There is a 1 million dollar prize for it. http://www.claymath.org/millennium/ General belief is that P != NP. 6. Informal definition of NP-Completeness. Formal definition will require time and care. But, to introduce it informally, we begin with definition of larger class NP: these are problems whose solutions have a polynomially "checkable" solutions. That is, if someone handed you the solution, you can verify it in poly time. E.g. Does a graph G have a simple (loopless) path of length K? Is a number composite? Does a graph have a vertex cover of size C? Clearly, all problems in P are also in NP, so P subset NP. 6a. NP-Complete problems are in a formal sense the "hardest" problems in NP---if any one of them can be solved in P, then they can ALL be solved in P; this would result in the set equality P = NP. Similarly, if any one of the NPC problem can be shown to require exponential time, then they all will be exp. 6b. NP is not the hardest class; there are harder ones. PSPACE: problems that can be solved using only a polynomial amount of space. (Thus, no regard for the time; exp algorithms often take only poly space.) EXPTIME: Problems that can be solved in exp time. It may be surprising that there are problems outside EXPTIME too! UNDECIDABLE: Problems for which no algorithm exists, no matter how much time is allowed. Suppose you're working on a lab for a programming class, have written your program, and start to run it. After five minutes, it is still going. Does this mean it's in an infinite loop, or is it just slow? 6c. How time complexity analysis and deep mathematics can be intertwined. It would be convenient if your compiler could tell you that your program has an infinite loop. However this is an undecidable problem: there is no program that will always correctly detect infinite loops. Some people have used this idea as evidence that people are inherently smarter than computers, since it shows that there are problems computers can't solve. However it's not clear to me that people can solve them either. Here's an example: main() { int x = 3; for (;;) { for (int a = 1; a <= x; a++) for (int b = 1; b <= x; b++) for (int c = 1; c <= x; c++) for (int i = 3; i <= x; i++) if(pow(a,i) + pow(b,i) == pow(c,i)) exit; x++; } } This program searches for solutions to Fermat's last theorem. Does it halt? (You can assume I'm using a multiple-precision integer package instead of built in integers, so don't worry about arithmetic overflow complications.) To be able to answer this, you have to understand the recent proof of Fermat's last theorem. There are many similar problems for which no proof is known, so we are clueless whether the corresponding programs halt. 7. Focus on DECISION PROBLEMS. While in CS, we often deal with optimization problems, it will be more convenient to discuss decision problems, that have YES/NO answers. For instance, consider the TSP problem in a graph with non-neg edge weights. Optimization: What is the minimum cost cycle that visits each node of G exactly once? Decision: Given an integer K, is there a cycle of length at most K visiting each node exactly once? Decision problems seems easier than optimization: given optimization solution, decision is easy to solve. However, since we are interested in hardness, showing that decision problem is hard will also imply hardness for the optimization. In general, for most problems, decision complexity is in the same class as optim. 8. REDUCTION BETWEEN PROBLEMS. This the hammer in the theory of NP-completeness. Reduction from problem A to B is a *poly-time* algorithm R that transforms inputs of A to equivalent inputs to B. That is, given an input x to A, R will produce an input R(x) to problem B such that "x is a "yes" input for A if and only if R(x) is a "yes" input for B." Mathematically, R is a reduction from A to B iff, for all x, A(x) = B(R(x)). Picture: When such a reduction exits, we write A <= B, suggesting that (give or take a polynomial), A is no harder than B. IMPORTANT IMPLICATION: If B is known to be easy => A is easy too. If A is known to be hard => B must be hard too. It's the second implication we use in NP-Completeness reductions. 9. Sample Problems to get a sense of the diversity of NPC. To show how similar they can be to P problems, we show them in pairs. A. MST: given a weighted graph and integer K, is there a TREE of weight <= K connecting all the nodes. TSP: given a weighted graph and integer K, is there a CYCLE of weight <= K connecting all the nodes. B. Euler Tour: given a directed graph, is there a closed path visiting every EDGE exactly once? Hamilton Tour: given a directed graph, is there a closed path visiting every NODE exactly once? C. Circuit Value: given a boolean circuit, and 0/1 values for inputs, is the output TRUE (1)? Circuit SAT: given a Boolean circuit, is there a 0/1 setting of inputs for which the output is 1? SATISFIABILITY: A central problems in theory of NPC. General circuits difficult to reason about, so we consider them in a standard form: CNF (conjunctive normal form). Let x1, x2, ..., Xn be input booleans, and let x_out be the output boolean variable. Then a boolean expression for x_out in terms of xi's is in CNF if it is the AND of a set of clauses, each of which is an OR of some subset of literals; input vars and their negations. Example: x_out = (x1 V x2 V !x3) ^ (x3 V !x1 V !x2) ^ (x1) This has an obvious translation to circuits, with one gate per logical operation. An expression is 2-CNF if each clause has 2 literals; and 3-CNF if each has 3 literals. Examples. (x1 V !x1) ^ (x3 V x2) ^ (!x1 V x3) is 2-CNF (x1 V !x1 V x2) ^ (x3 V x2 V !x1) ^ (!x1 V x3 V !x2) is 3-CNF APPLICATIONS OF SATISFIABILITY: Model-checking, Design Debugging Circuit delay computation functional dependence AI planning Inference in bioinformatics Knowledge-compilation, Software testing Package management in software distributions Checking of pedigree consistency test-pattern generation in digital systems Crosstalk noise prediction in integrated circuits termination analysis in term-rewrite system D. 2-CNF: given a boolean formula in 2-CNF, is there a satisfying assignment. 3-CNF: given a boolean formula in 3-CNF, is there a satisfying assignment. E. Matching: given a boys-girls compatibility graph, is there a complete matching? 3D Matching: given a boys-girls-houses tri-partite graph, is there a complete matching; i.e. set of disjoint boy-girl-house triangles? 10. NP and NP-Completeness. Intuitively, a problem is in NP if all YES instances have a polynomial-size and polynomial-time checkable solution. In all the examples about this is the case. Thus, clearly every problem in P is also in NP. A problem A \in NP is NP-Complete if EVERY other problem X \in NP is reducible to A. Lemma: If A is NP-Complete, then A is in P iff P = NP. ============================================================== Lecture 2 on NP-Completeness. 1. Recap: NP is the class of decision problems whose YES instances have polynomial-time checkable proofs. A problem A is NP-Hard if EVERY problem in NP has a reduction to A. A problem A is NP-Complete if it is NP-Hard AND it belongs in NP. Remember not all problems have polynomially-checkable solutions. Take, for instance, the Halting Problem, or generalized Chess. 2. CSAT and NP-Completeness. To get the theory going, we need to establish at least one NPC problem. We will reason that Circuit-SAT is such a problem. First, CSAT is clearly in NP; given an instance C, and a "satisfying" setting of booleans x1, x2, ..., xn, we just simulate the circuit, and check if xout = 1. The hard part is show that EVERY other problem in NP reduces to CSAT. Recall the implications of A <= CSAT; if CSAT is easy, then all A's are easy too; if ANY A is hard, then CSAT is hard too. This is Cook's Theorem (1971), and difficult result. We will give an informal proof sketch later, but for now let us assume CSAT is hard and use that to prove intractability of other problems. (Karp 1970s). 3. Overall plan Boolean SAT => 3SAT 3SAT => Max Independent Set (MIS) MIS => CLIQUE MIS => Vertex Cover 3SAT => Hamiltonian Cycle 3SAT => Subset SUM 4. We take an instance of SAT, and convert into a poly-size instance of 3-SAT, as follows. Leave alone any clause with exactly 3 literals. For the rest: If a clause has exactly one literal, as (x), then replace it: (x V y1 V y2) ^ (x V y1 V !y2) ^ (x V !y1 V y2) ^ (x V !y1 V !y2) where y1, y2 are 2 new variables introduced just for this clause. If clause has length 2, such as x1 V x2, we do (x1 V x1 V y) ^ (x1 V x2 !y) If clause has 4 or more literals, as (x1 V x2 V ... V xk): (x1 V x2 V y1) ^ (!y1 V x3 V y2) ^ (!y2 V x4 V y3) ... [If shorter clauses, we can set vars y arbitrarily. For longer clauses, some care is needed.] 5. MAXIMUM INDEPENDENT SET: Given an undirected, unweighted graph G = (V, E), an Independent Set is a subset I of V in which no two vertices are adjacent. (A classical problem, modeling conflicts among tasks, with many applications.) DECISION VERSION: Given a graph G, and an integer k, does G have an Ind Set of size at least k? Membership in NP is easy; just check that no two vertices of I have an edge between them. To show NP-Completeness, we reduce 3SAT to MIS. Starting with a formula of n vars x1, ..., xn, and m clauses, construct a graph with 3m vertices. This graph has an IS of size m if and only if the 3SAT formula is satisfiable. Construction: The graph G has a triangle for every clause. The vertices in the triangle correspond to the 3 literals in that clause. Vertices in different clauses are joined by an edge IFF those vertices correspond to literals that are negations of each other. EXAMPLE: (from KT) (!x1 V x2 V x3) ^ (x1 V !x2 V x3) ^ (!x1 V x2 V x4) Proof of Correctness. Formula satisfiable ==> IS of size m. Suppose formula is satisfiable. Thus, in each clause, at least one literal is satisfied. Construct the IS as follows: pick exactly one vertex corresponding to a satisfied literal in each clause (break ties arbitrarily). No two such vertices can have an edge between them---within each triangle (clause), we choose only vertex, and across triangles each edge joins literals that are negations of each other, so our construction will not pick both. So, the resulting set of vertices is an IS and it has exactly m vertices. IS ==> Satisfiable. Suppose we have an IS with m vertices. We can have only one vertex in each triangle, since two are always adjacent. We make the variable assignment so that these chosen literals are true. This will consistently satisfy all the clauses. End of proof. 6. MAX CLIQUE. Given a graph G (undirected, unweighted), a CLIQUE is a set of vertices K such that EVERY pair is adjacent. Decision Version: Given G and an integer k, does G contain a CLIQUE of size at least k? Membership in NP is easy. For the NP-Completeness, we actually reduce the MIS problem to CLIQUE. Take an instance (G, k) of MIS. Construct the complement graph G' which has the same vertex set as G, but there is an edge (u,v) in G' EXACTLY when (u,v) is NOT an edge in G. Now, an IS in G' must be a clique in G and every clique in G is an IS in G'. Thus, G' has a k-clique if and only if G has a k-vertex IS. 7. VERTEX COVER: Given a graph G, a vertex cover C is a subset of vertices such that every edge (u,v) in G has either u or v (or both) in C. In the MIN VC problem, we want to find the cover of smallest size. In the Decision Version, we want to decide if G has a vertex cover of size at most k. Membership in NP is straightforward; just check if all edges have at least one endpoint in the cover. For the NP-Completeness, we show reduction from MIS. Lemma. Suppose I is an Independent Set in G = (V, E). Then, the remaining vertices (V - I) form a vertex cover in G. Conversely, if C is a VC in G, then (V - C) is an IS of G. Proof. Let I be an IS of G, and let C = V - I. For the sake of contradiction suppose C fails to be a vertex cover. Then there is at least one edge (u,v) for which neither u nor v is in C. This means that both u and v are in I = V - C, but that's a contradiction because u and v are not independent. Conversely, suppose I = (V - C) is not an independent set. Then there is some edge (u,v) for which both u and v are in I. But then C = V - I is not a vertex cover; it doesn't cover (u,v). Thus G has a MIS of size k if and only if G has a VC of size n-k. 8. Back to Cook's proof. Instead of Boolean SAT, we prove hardness of Circuit-SAT. Conversion between Boolean SAT and Circuit SAT is easy. Intuitive idea: Any problem X in NP has the property that a YES answer can be checked in poly time. This can be transformed into a circuit, whose input variables are the solution bits and the output bit = 1 iff the input forms a solution. The circuit has polynomial size. But the CSAT is able to decide if there is ANY setting of the input variables that makes the output = 1, which means CSAT can solve the problem X using this circuit, under a poly reduction.) 9. Suppose A is a decision problem that is solvable in p(n) time by some program P, where n is the input size (in bits). Then, for every fixed n, there is a circuit Cn of size about O( (p(n))^2 (log p(n))^k) such that for every input x = (x1, .., xn), A(x) = Cn(x1, ..., xn). That is, the circuit Cn solves problem A on all inputs of length n. Proof Idea. Assume the program P is written in some low-level machine language (or compile it). Because P takes at most p(n) steps, it can access at most p(n) memory cells. So, at any step, the "global state" of the program is given by the contents of these p(n) cells plus O(1) program counters. No register/cell needs to contain numbers bigger than log p(n) = O(log n) bits. Set q(n) = (p(n) + O(1)) O(log n) be the size of the global state. We maintain a "q(n) x p(n)" tableau that describes the computation. The row i of the table is the state at time i. Each row of the table can be computed starting from the previous row by means of an O(q(n)) size circuit. (In fact, the microprocessor that executes the program P is such a circuit.) End of Proof. There are a bunch of technical details and fine points, but this is the general idea. NOTE that we don't need to know anything about P; the proof only uses the fact that it runs in time p(n). Now, to show that every NP problem reduces to CSAT, take the example of HAM cycle. Given a graph G, with n vertices and m edges, we build a circuit that outputs 1 iff G is Hamiltonian. How? Well, there is a computer program that checks in polynomial time if a given sequence of edges is HAM. So, there is a circuit that can do the same. Then, we "hard wire" G into the circuit. More concretely: We now try to show that X <=p CircuitSAT, for all X \in NP. That is, given an input s, we want to decide if s is a YES instance of X or not, using a blackbox that solves CircuitSAT. All we know about X is that it is in NP, that is, it has an efficient (poly-size) certificate B. So, to determine whether s is YES, we need to decide if there is a t (certificate) of length p(n) such that B(s,t) = YES. We can answer this question by appealing to our blackbox, as follows. View B(s,t) as an algorithm on n + p(n) bits of input, which can be simulated by a circuit of size polynomial in n + p(n). The first n bits are hard-coded with the input n bits; the remaining p(n) sources are the variables, representing the certificate. Now, s is a YES instance if and only if there is some setting of these p(n) variables so that the circuit produces the output 1. Thus, X <=p circuitSAT. Circuit is a Yes-instance CSAT if and only G is Hamiltonian. 9. Proving More NP-Completeness Results If A <= B, and B <= C, then A <= C. Former implies a poly time function f such that A(x) = B(f(x)). Latter implies a poly time function g such that B(y) = C(g(y)). Thus, A(x) = C(g(f(x)), and g(f()) is clearly poly-time. Lemma. Suppose C is a NP-C problem, and A is some problem in NP. If we can show that C reduces to A, then A must be NP-C. (By NP-C, all problems in NP can reduce to C; since C reduces to A; by previous observation, all problems also reduce to A.) 10. NP-Completeness of HAMILTON Cycle: Given a directed graph G = (V, E), is there a simple cycle (tour) T visiting each vertex of V exactly once? The problem is in NP clearly: given a tour T C, verifying that is HAM is easy: check that it visits each vertex exactly once, and that each edge is in E. a. Why reduce from 3SAT? In part because we don't know what else to do. No other problem we know so far (Vertex Cover, MIS etc) seems related to a cycle. Consider an (arbitrary) instance of 3-SAT, with variables x1, ..., xn, and clauses C1, C2, ..., Ck. We show how to solve the 3SAT, given the power to decide if a graph has a HAM cycle or not. b. We begin by describing a graph that has 2^n different cycles that correspond in a natural way to the 2^n possible truth assignments to variables xi. After that we add nodes to model constraints imposed by clauses. c. Construct n paths P1, P2, ..., Pn, where Pi consists of nods vi1, ..., vib, for b = 3k + 3, where recall that k is the number of clauses. There are edges between vij and vi,j+1, in both directions. Thus, Pi can be traversed from "left to right" or from "right to left". We then hook up these n paths as shown below: s O1 --- O --- O ............ Ob O1 --- O --- O ............ Ob O1 --- O --- O ............ Ob t Join each O1 to O1 and Ob in the next row; similarly, join each Ob to O1 and Ob in the next row. Finally, join edges from s to O1 and Ob in first row, from O1 and Ob in last row to t, and one edge from t to s. d. Consider what the HAM cycle in this graph looks like. After entering s, the path can take P1 left-right or right-left; and regardless of how it traverse P1, it can then do the same for P2, etc etc, until it finishes Pn, and then enters t, and then finally take the edge from t to s. Thus, it has precisely 2^n ways to form a HAM cycle in this graph. Each path Pi, thus, models an independent choice for setting the variable xi: left-to-right means xi = 1; right-to-left means xi = 0. e. Now we add extra nodes to model clauses, so that the final graph has a HAM cycle iff the formula is satisfiable. Consider a clause (x1 V not x2 V x3) In the language of HAM cycle this clause is saying that the cycle should traverse P1 "left to right" OR it should traverse P2 "right-to-left" OR it should traverse P3 "left to right". (At least one of these should be true.) So, we add a node c1 (for clause 1) that forces just this. For each clause cj, we will reserve two adjacent node positions (3j and 3j+1) in each path where cj can be spliced. If cj contains un-negated variable xi, then we add edges from vi,3j to cj, and back edge from cj to vi,3j+1. If xi is negated in cj, then we add an edge from vi,3j+1 to cj, and a back edge from cj to vi,3j. Thus, the node cj can be easily spliced into the HAM cycle if the cycle traverses path Pi corresponding to xi in correct direction (left to right for 1 and right to left for 0).. f. This completes the construction. Now, first, suppose 3SAT is satisfiable. Then we form a HAM cycle following our plan: if xi is set to 1, traverse path P1 left to right; otherwise right to left. For each clause cj, since it is satisfied by assignment, there will be at least one path Pi in it that is going in the "correct" direction *relative* to cj, and so we can splice cj into it via edges incident to vi,3j and vi,3j+1. Conversely, suppose the graph has a HAM cycle. If the cycle enters a node cj on edge from vi,3j, it must depart on an edge vi,3j+1. If not, then vi,3j+1 will have only one un-visited neighbor left, namely, vi,3j+2, and so the tour will not be able to visit this node and maintain HAM property. Symmetrically, if the tour enters vi,3j+1, it must depart immediately to vi,3j. =================================================================== Lecture 3 on NP-Completeness. The classical reference is Computers and Intractability A guide to the theory of NP-Completeness Michael Garey and David Johnson W H Freeman, 1979. *. Some NP-Complete Numerical Problems. 1. SUBSET SUM. Given a sequence of integers a1, ...,an, and a parameter k, decide if there is a subset of integers that sum to exactly k. It's a true decision problem, not an optimization problem forced into a decision version. Membership in NP is easy. For the completeness part, we reduce Vertex Cover to Subset Sum. Outline: o. Start with G and parameter k. o. Create a sequence of integers and parameter k' o. Prove that G has VC of size k if and only if there is subset of integers that sum to k' Reduction. For simplicity, assume the vertices of G are labeled 1, 2, ..., n. We define an integer ai for vertex i, an integer b_ij for each edge (i,j), and finally an integer k'. Our reduction will have the property that if there is a subset of ai's and b_ij's that sum to k', then: the subset of chosen ai's form a vertex cover, and the set of chosen b_ij's correspond to edges in G with exactly one endpoint in the cover. Furthermore, the size of the cover will be exactly k. Represent the integers in a matrix form. Each integer is a row, and the row should be seen as base-4 representation of the integer, with |E| + 1 digits. The first column of the matrix (the most significant digit) is a special one: it contains 1 for the ai's and 0 for the b_ij's. Then, there is a column (digit) for each edge. The column (i,j) has a 1 in a_i, a_j, and b_ij, and 0's everywhere else. The parameter k' is defined as k' = k(4^|E|) + \sum_{i=0}^{|E|-1} 2 (4^i) Analysis. Cover ==> Subset Sum. If there is a vertex cover of size k, then choose all integers ai for which i is in C, and all b_ij such that exactly one of i, j is in C. Then, when we sum all these integers, doing operations in base 4, we have a 2 in all digits except for the most significant one. In the MSD, we are summing one |C|=k times. Thus, the sum of integers is k'. Subset Sum ==> Cover. Suppose we find a subset C of V and E' of E such that \sum_{i \in C} ai + \sum_{(i,j) \in E'} b_ij = k' First, note that we never have a carry in the |E| less significant digits; operations are base 4, and there are at most 3 ones in each column. Since the b_ij can contribute at most 1 in every column, and k' has a 2 in all the |E| less significant digits, it means that for every edge (i,j), C must contain either i or j. So, C is a cover. Every ai is at least 4^|E|, and k' gives a quotient of k when divided by 4^|E|. So, k's cannot have more than k elements. End of proof. 2. PARTITION. Given a sequence of integers a1, ..., an, determine if there is a partition into two subsets with equal sums. Formally, is there a subset I of {1, 2, .., n} such that \sum_{i \in I} a_i = \sum_{i \not\in I} a_i. PARTITION is clearly a special case of sumset sum; the k here is just half the total sum of elements. 3. BIN PACKING. One of the most widely studied problems in CS and OR, perhaps the second most after TSP. Given items of size a1, a2, .., an, and given an unlimited supply of bins, each of size B, we want to pack items into the fewest possible bins. The decision version is to decide if the items can be packed in k or fewer binds. Clearly, an NP problems. For NP-Completeness we can reduce the PARTITION. Given an instance of PARTITION {a1, a2, ..., an}, create items of size a1, a2, ..., an. Let S = \sum a_i, be their total size. Make bin size B to be S/2, and let k = 2. The items can be packed in 2 bins if and only if the partition has a solution. 4. KNAPSACK. Subset Sum is a special case of the Knapsack problem. An instance of the Subset Sum has integers a1, ...,an, and a parameter k, and the goal is to decide if there is a subset of integers that sum to exactly k. We can frame this as a knapsack problem by introducing n items, where item i has both size and value equal to ai. The knapsack size is k. Now, the Subset Sum problem has answer YES if and only if the Knapsack problem has a solution with value k. (Because the size and value are equal, the knapsack can achieve value k only if it can be packed completely.) ================================================================= Let's start with one example. Euler Tour: The story goes that the graph theory began with a puzzle facing the great mathematician Leonhard Euler (1707-1783). The town of Konigsberg is spanned by both banks of the river Pregel, and two islands in it. Seven bridges connected both banks and both islands with each other. Euler was puzzled by the fact that no matter where he started, he could never take a walk that crossed each bridge exactly once. Being a mathematician, he abstracted the problem as follows: picture. Then, asked a graph-theoretic problem: is there a path that visits each edge exactly once? Rudrata Tour: A hundred years before Euler, an Indian poet posed the following Chess problem: Is there a Knight's tour visiting all the squares of the board? When posed in graph theoretical terms, the two problem admittedly look quite similar. So, it's puzzling that we know how to solve the first one efficiently (quite easily in fact); while no sub-exp algorithm is known for the latter.