With a global variable closed list.

```
map = {}
map[None] = None
class Solution:
# @param node, a undirected graph node
# @return a undirected graph node
def cloneGraph(self, node):
if not node:
return None
head = UndirectedGraphNode(node.label)
map[node] = head
for n in node.neighbors:
if n in map:
head.neighbors.append(map[n])
else:
neigh = self.cloneGraph(n)
head.neighbors.append(neigh)
return head
```