Rewrote Kamada-Kawai layout generator (#588).