update logic to deal with nodes without outgoing edges