Also, this heap stores the neighbors and indices in place, so no copying is required at the end of the tree traversal.