Shortest path algorithm with linked list

Started by
1 comment, last by Carolina 18 years, 10 months ago
Hi!Here I am again,in trouble as always XD My mission is to implement a version of Dijkstra´s Algorithm(that finds the shortest path between two points) using a Linked List instead of the commom matrix of distance values. I only want to know how any of you would implement the "relaxation" part of the algorithm(that part in which it is made a comparison between a vector of distances D and a matrix of values input by the user). Thanks in advance!
Advertisement
I really wouldn't implement it using a linked list. A hash-map from node ID to cost, or a vector (or a vector of vector) maybe, but never a linked list. Finding the right node to update would be O(N) and would cache poorly (because each node can be a new cache line).
enum Bool { True, False, FileNotFound };
Well,I wouldn´t implement it using a linked list either,but my teacher is nuts and he wants it delivered today!Whoa,I´m such a lucky student XD

This topic is closed to new replies.

Advertisement