One way to compute this that I have seen in the literature is to first compute the distance transform (as outlined earlier); then, a vertex occurs wherever there is a local maximum of this function, and vertices are connected by walking along the direction of least change of the distance transform to form edges.