now using Graph class in place of tree implementation, but repositioning is broken