transitive closure With Path

I've taken the code for transitive closures and added paths into it