renamed edge field to weight for clarity and added reduceToMaxWeight