modify algorithm to not barf on topologies with a bridge edge