Search code examples
algorithmgraphpath-findingnp-complete

Find a positive simple s-t Path on a Graph is NP-Complete?


I'm trying to find something on the literature to help me to solve this problem:

Given a graph with non negative edge weights, find a simple s-t positive path of any size, i.e., a path that goes from s to t with length greater than 0. I was trying to use dijkstra algorithm to find a positive shortest path by avoiding relax the edges that have cost zero, but this is wrong. I don't want to believe that this problem is NP-Complete =/. Sometimes it seems to be NP-Complete, because there may be a case where the only positive path is the longest path. But this is such a specific case. I think that on this kind of instance the longest path problem is polynomially solvable.

Can someone help me identifying this problem or showing that it is NP-Complete ?

Observations: The only requirement is to be some positive path (not necessarily the lowest or longest). In case of multiple positive paths it can be anyone. In case of non existence of such path, the algorithm should flag that the graph has no positive path.


Solution

  • The problem is NP-complete even with only one single edge having value 1, and all the others having value 0. Reduce from Two Directed Paths:

    Two Directed Paths
    Input: A directed graph G and two pairs of vertices (s1, t1) and (s2, t2)
    Output: Two vertex-disjoint paths, one from s1 to t1 and from from s2 to t2.

    Create a new instance with all edges having weight 0, and create an edge from t1 to s2 with weight 1.