Working djikstra's algorithm creating graph of random degree