Diameter function implemented