Refactor value checks for unweighted graphs.