djikstra's algorithm and all 2.2 functionality