Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I have the following (directed, edge-weighted) graph problem. In a set of n vertices, G, there is a source vertex, s. I need to compute the shortest path between s and every other vertex.

I can't use Dijkstra directly since edge distances can be negative. The graph also has cycles. I realize that one can go round and round to make the total distance as low as one wants. However, I would like to find the shortest path (in terms of edge weight sums) from s to a given node, such that the path does not have any cycles.

Am I thinking about this the wrong way?

share|improve this question

1 Answer 1

I'm not sure, but this seems to be NP-hard. Here is why.

Suppose you have an algorithm to find the simple path (i.e. path without cycles) with minimal weight between any two nodes. Using this algorithm, you can make an algorithm for finding the longest (in terms of number of edges) simple path between any two nodes simply by assigning weight $-1$ to all edges. And you can use this second algorithm to solve the Hamiltonian path problem, which is NP-complete.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.