Graph traversal in data structure