Optimized Longest Path Problem: The optimized longest path problem states that given a graph G, of a set of vertices V and edges E, the task is to prove that there is a path of length at least K between a set of nodes V_{s} and V_{e}.
Problem Statement: Given a graph G(V, E, K) and a set of nodes V_{s} and V_{e} with the sequence of nodes, of length ≥ K.
Explanation:
An instance of the problem is an input specified to the problem. An instance of the optimizedlongest path problem is G(V, E, V_{s}, V_{e}, K). Since an NPcomplete problem is a problem which is both in NP and NPHard, the proof for the statement that a problem is NPComplete consists of two parts:
 The problem itself is in NP class.
 All other problems in NP class can be polynomialtime reducible to that.
(B is polynomialtime reducible to C is denoted as B≤P^{C})
If the 2nd condition is only satisfied then the problem is called NPHard.
But it is not possible to reduce every NP problem into another NP problem to show its NPCompleteness all the time. That is why if we want to show a problem is NPComplete we just show that the problem is in NP and any NPComplete problem is reducible to that then we are done, i.e. if B is NPComplete and B ≤ P^{C }For C in NP, then C is NPComplete. Thus, we can verify that the Optimized Longest Path Problem is NPComplete using the following two propositions:

Optimizedlongest Path Problem is in NP:
If any problem is in NP, given a ‘certificate’, which is a solution to the problem and an instance of the problem then it can be verified (check whether the solution given is correct or not) that the certificate in polynomial time. This can be done by a path P, consisting of a set of vertices < V_{1}, V_{2}, V_{3}, ….V_{n} >. Verify if the path connects V_{1}, and V_{n} completely and the length of the path is at most K. 
Optimizedlongest Path Problem is NPHard:
In order to prove that the Longest Path is NPHard, deduce a reduction from a known NPHard to the problem. Carry out a reduction in which an undirected Hamiltonian Path problem can be reduced to the Longest Path problem. The undirected hamiltonian path uses the input a graph G(V_{1}, V_{n}) where graph G has nodes V_{1} and V_{n}. Undirected Hamiltonian Path is an Undirected path along the graph starting at one vertex and ending at another traversing all nodes.Now, let K be the numbers of nodes in G. Every instance of Undirected Hamiltonian Path can be converted to the Longest Path in the following way:
For input G(V_{1}, V_{n}), output G(V_{1}, V_{n}, k). This reduction takes polynomial time by simply counting the number of vertices in G. The reduction can be proved by the following two propositions: Assume the original graph G(V, E) is provided with nodes V_{1} and V_{n} has an undirected Hamiltonian path, which traverses all the vertices, therefore G(V, E, K) is true because any two nodes in G will be connected by a path of length equal to its nodes i.e., K therefore Longest Path problem holds.
 Let us assume the graph G'(V, E, V_{s}, V_{e}, K) has a Lpath of length K from V_{s} to V_{e}, which implies G’ contains a simple path of length K from V_{s} to V_{e}.
But, G contains K vertices, hence traverses all vertices starting at V_{s} and ending at V_{e} forming a hamiltonian path, G'(V_{s}, V_{e}).Let V_{1} ≡ B and V_{n} ≡ D
Now, G has an Undirected Hamiltonian Path ≡ BCAD of K = 4.
Therefore, G contains an optimized path of length = 4 between B and D.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a studentfriendly price and become industry ready.
Recommended Posts:
 UnionFind Algorithm  (Union By Rank and Find by Optimized Path Compression)
 Proof that Hamiltonian Path is NPComplete
 Dial's Algorithm (Optimized Dijkstra for small range weights)
 Shortest path from source to destination such that edge weights along path are alternatively increasing and decreasing
 Longest Path in a Directed Acyclic Graph
 Longest Path in a Directed Acyclic Graph  Set 2
 Longest path between any pair of vertices
 Longest path in a directed Acyclic graph  Dynamic Programming
 Algorithms  NP Complete  Question 1
 Algorithms  NP Complete  Question 2
 Algorithms  NP Complete  Question 3
 Algorithms  NP Complete  Question 4
 Algorithms  NP Complete  Question 5
 Algorithms  NP Complete  Question 6
 Proof that vertex cover is NP complete
 Maximum Possible Edge Disjoint Spanning Tree From a Complete Graph
 Program to find total number of edges in a Complete Graph
 Minimum operations of the given type required to make a complete graph
 Ways to Remove Edges from a Complete Graph to make Odd Edges
 The complete History of Java Programming Language
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.