writing the doubleDijkstra -MCM