![]() |
|
#1
|
|||
|
|||
Algorithm: shortest paths to every vertex of GCan you tell me some ideas for an efficient algorithm on this problem?
We have a directed graph and a function of weight w we know that there is only one edge with a negative weight and that there is no cycle in the graph with negative weight we have s a vertex We have to find an algorithm that find the length of all the shortest paths from s to every vertex of G |
|||
|
#2
|
||||
|
||||
Re: Algorithm: shortest paths to every vertex of GDijkstra's algorithm doesn't allow negative-weight edges, but you can still apply it to this problem. Let (i, j) be the negative-weight edge. Then:
Thus you need to check both possibilities for every vertex and see which is better. This is the fastest way I can think of off the top of my head. Bellman-Ford allows for negative-weight edges, but it's not as efficient as Dikstra. __________________
www.blake-foster.com |
Recent GIDBlog
Install Adobe Flash - Without Administrator Rights by LocalTech
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Shortest Path for Airport | mxb1145 | C++ Forum | 1 | 16-Dec-2008 06:28 |
| Need Help - Shortest Path Problem | mas287 | C Programming Language | 5 | 18-Jun-2008 02:59 |
| Shortest Path Program. | bomber456 | C++ Forum | 1 | 05-Mar-2007 12:32 |
| all shortest paths with dijkstra | cpit | C++ Forum | 0 | 05-Jun-2006 10:07 |
| shorthest path-another way | Pandiani | C++ Forum | 6 | 09-May-2004 19:51 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The