Adding vertex reduce function