graph's depth bugfix.

global depth value was being updated whithin the recursive calls.
Now each recursive call as a local copy of the depth value.