Dijkstra and grid cells?

327 Views Asked by At

I have a problem with Dijkstra's algorithm. I'm trying to calculate the shortest transport time between all cells in a grid used by a general circulation model (think oceanography or meteorology). the NxN matrix of weights consists of the shortest time it takes for a particle to move from one grid cell to any other, with plenty of cells not having a connection.

My problem is that the cost to cross a cell isn't included when using Dijkstra's algortithm witch gives many jumps an advantage. Is there an alternative algorithm where you can provide a cost for the jumps between nodes?

An example:

   (0)
 7/   \1
(1)   (2)
1|     |1
(3)   (4)
 1\   /1
   (5)

The path (0) -> (1) cost 7 with one jump The path (0) -> (2) -> (4) -> (5) -> (3) -> (1) cost 5 with 5 jumps

I'd like to be able to provide a weighting cost for each respective extra jump in the second case.