Refactor UpdateDependencyGraph

1. Refactor UpdateDependencyGraph  such that it only returns the
reachable graph nodes
2. Mark reachable graphnodes as dirty after calling
UpdateDependencyGraph