updates to transition matrix and depth first search