Adding this ordered graph code, chaning my implementation but this can still be useful at times