adding the complete working version of the dijkstras algorithm