How to show that the shortest simple path problem between two vertices $s$ and $t$ (finding a minimum weight path between $s$ and $t$) in a graph is NP-complete? I saw the following proof in a combinatorial optimization lecture, which I didn't understood (I stressed the moment that I didn't understand).
Let $P_1$ be the Hamiltonian path problem:
The Hamiltonian path problem and the Hamiltonian cycle problem are problems of determining whether a Hamiltonian path (a path in an undirected or directed graph that visits each vertex exactly once) or a Hamiltonian cycle exists in a given graph (whether directed or undirected). Both problems are NP-complete. From Wikipedia.
Does it exists an Hamiltonian path in $G$?
Let $P_2$ be the shortest path problem in a directed graph.
If $G$ is the graph within which we search such a Hamiltonian path, we transform $G$ into $\hat G$, replacing each edge $(i,j)$ with two edges $(i,j)$ and $(j,i)$.
For each edge $\{i,j\}$ in $G$, we erase $(i,j)$ and $(j,i)$ from $\hat{G}$, give a weight of $-1$ to all remaining edges, and calculate the shortest (simple) path from $i$ to $j$. If the path length is $-(n-1)$, then this is a Hamiltonian path in $G$. If we found no such path going over all edges, then $G$ has no Hamiltonian path.
- Why is is the case that if the path has length $-(n-1)$ then it constitutes a Hamiltonian path in $G$?
- Why if not such path has length $-(n-1)$ then $G$ has no Hamiltonian path?
Maybe if you were kind to help me understand with a visual example I would better understand?
Last but not least, how did we proves that Hamiltonian path is NP-complete?