- #1
evinda
Gold Member
MHB
- 3,836
- 0
Hello! (Smile)
Longest path
We have a graph $G=(V,E)$, lengths $l(e) \in \mathbb{Z}^{+}$ for each $e \in E$, a positive integer $K$ and two nodes $s,t \in V$.
The question is if there is a simple path in $G$ from $s$ to $t$ of length at least $K$.
Could you give me a hint how we could show that the problem belongs to NP? Also, how can we reduce a problem to an other, in order to show that the latter is NP-complete?
Longest path
We have a graph $G=(V,E)$, lengths $l(e) \in \mathbb{Z}^{+}$ for each $e \in E$, a positive integer $K$ and two nodes $s,t \in V$.
The question is if there is a simple path in $G$ from $s$ to $t$ of length at least $K$.
- Show that the problem Longest Path belongs to NP.
- Show that the problem Longest Path is NP-complete, reducing Hamiltonian Path to it.
- Show that if the graph is directed and acyclic then the problem can be solved in time $O(|V|+|E|)$.
Could you give me a hint how we could show that the problem belongs to NP? Also, how can we reduce a problem to an other, in order to show that the latter is NP-complete?