Have graph working but algo seems wrong