Added permutation using graph and Djikstra's