Reorganize graph so that it is more efficient.