small changes to graph theory problem