Graph repositioning as a tree