Click here to Skip to main content
15,889,845 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
In my economics research I am currently dealing with a specific shortest path problem:

Given a directed deterministic dynamic graph with weights on the edges, I need to find the shortest path from one source S, which goes through N edges. The graph can have cycles, the edge weights could be negative, and the path is allowed to go through a vertex or edge more than once.

Is there an efficient algorithm for this problem?

What I have tried:

For now I can only compute shortest path when I know the final vertex as a constraint, but now I want my constraint to be on the number of edges the paths go through and not on the final vertex.
Posted
Updated 29-Jun-18 6:33am
Comments
[no name] 29-Jun-18 20:01pm    
So you're saying I can "reverse" in order to "shorten" my path by picking a negative edge that returns to a previous vertex that has any number of edges?

The potential then exists to cycle into a negative black hole?

1 solution

Quote:
Is there an efficient algorithm for this problem?

None, even worse there can be no solution because of infinite looping.
Quote:
The graph can have cycles, the edge weights could be negative, and the path is allowed to go through a vertex or edge more than once.

The combination of those criteria can lead to infinite loops.
If you have a loop with negative cost, just 1 more loop will improve any best path infinitely.
Negatives costs prevent any optimization.

You have to rethink your criteria or give details.
 
Share this answer
 
Comments
Alexandre Cornet 29-Jun-18 15:56pm    
You have to explain me how there can be an infinite loop with only N edges ;)
Maybe I forgot to precise that N is a finite natural number...
thanks anyway.
Patrice T 29-Jun-18 16:09pm    
You stated : 'the edge weights could be negative, and the path is allowed to go through a vertex or edge more than once.'
This imply possible infinite loop.
Alexandre Cornet 29-Jun-18 16:13pm    
Such loops may exists but I am only looking at path with a finite number of edges. Therefore I would have guessed that because of this finite number of edge constraint this kind of loop would not be a problem.
Patrice T 29-Jun-18 16:28pm    
Path with limited number of steps is same as shortest path!
Alexandre Cornet 29-Jun-18 16:42pm    
by shortest path I meant : the path with the least weight not the least edges.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900