Midpoint routing algorithm implementation