By the way, is the graph directed actually

```
# Definition for a undirected graph node
# class UndirectedGraphNode(object):
# def __init__(self, x):
# self.label = x
# self.neighbors = []
class Solution(object):
def __init__(self):
self.visited = {}
def cloneGraph(self, node):
"""
:type node: UndirectedGraphNode
:rtype: UndirectedGraphNode
"""
if node == None: return None
graph = UndirectedGraphNode(node.label)
self.visited[node.label] = graph
for n in node.neighbors:
if n.label in self.visited:
graph.neighbors.append(self.visited[n.label])
else:
graph.neighbors.append(self.cloneGraph(n))
return graph
```