implemented graph traversals