Before I give you a detailed explanantion and yes..even a code section I would like to know underwhat circumstanses your pathfinding is taking place. Dijkstra's Algorithm is very limited and is best for calculating shortest distances on maps and such where there are set nodes, arcs and arc distances.