Created Transitive closure to check reachability