3

Given a graph $G=(V,E)$, and positive and negative edge weights, we would like to understand if there is a simple path with negative total weight from $s$ to $t$ where $s,t \in V$

My approach was to reduce this from the Hamiltonian path and I know I should somehow force the solver to go through as many vertices as it can to get a Hamiltonian path but I am not sure how to construct such a reduction

wizz
  • 165
  • 8

2 Answers2

2

You can reduce from the Hamiltonian path problem. Given an instance of the Hamiltonian path problem with $n$ vertices:

  1. Add a start vertex $s$ and an ending vertex $t$.

  2. For every vertex $v$ that is not $s$ or $t$, add edges $(s, v)$ and $(v, t)$ with weight $n-1$ and $n-2$ respectively.

  3. For every other edge, assign it weight $-2$.

Now the previous graph has an Hamiltonian path if and only if there is a simple path with negative total weight from $s$ to $t$ in the new graph.

xskxzr
  • 7,613
  • 5
  • 24
  • 47
1

Let $G=(V,E)$ be an instance of Hamiltonian $st$-path. Construct an instance of negative $st$-path $G'$ such that $G' = G$ with a new vertex $t'$ and the edge $tt'$ added. Set the weight of $tt'$ to $|V|-2$ and every other edge weight to $-1$.

The claim is that $G$ has a Hamiltonian $st$-path iff $G'$ has a negative $tt'$-path.

  • In the first direction, let $P$ be a Hamiltonian $st$-path in $G$. By definition, $P$ visits each vertex exactly once, so $P$ has total weight $1-|V|$ in $G$. So by taking $P \cup \{t,t'\}$ we have a path from $s$ to $t'$ in $G'$ with total weight $1-|V|+|V|-2 = -1$, as required.

  • In the second direction, suppose that there is a negative $st'$-path $P$ in $G'$. Because $t'$ has degree 1, any such $P$ must use the edge $tt'$ which has weight $|V|-2$. Further, as $P$ has negative total weight and the weight of every other edge is $-1$, it holds that $P$ also uses at least $|V|-1$ edges. In fact, as $P$ is simple, it uses exactly $|V|-1$ edges all of which are in $G$. So by taking $P \setminus \{t,t'\}$ we obtain a Hamiltonian $st$-path in $G$.

This completes the proof.

Juho
  • 22,905
  • 7
  • 63
  • 117