Graph layout algorithm