def cloneGraph(self, node):
        """
        bfs with visited
        similar to 138 Copy List with Random Pointer

        copy_map: dict, 1. book keeping whether it is coped (visited); 2. reserve for being copied as neighbor, # shadow
        q: list, queue of nodes whose the neighbors are to be copied

        :param node: UndirectedGraphNode
        :return: UndirectedGraphNode
        """
        if not node:
            return

        original2copy = {} # dict  #!important
        q = [node]  # queue of nodes whose the neighbors are to be copied

        clone = UndirectedGraphNode(node.label)
        original2copy[node] = clone
        while q:
            cur = q.pop()
            for neighbor in cur.neighbors:
                if neighbor in original2copy:  # already copied
                    original2copy[cur].neighbors.append(original2copy[neighbor])
                else:
                    q.append(neighbor)
                    clone_neighbor = UndirectedGraphNode(neighbor.label)
                    original2copy[neighbor] = clone_neighbor
                    original2copy[cur].neighbors.append(original2copy[neighbor])

        return original2copy[node]
dataset/ETHPy150Open algorhythms/LeetCode/133 Clone Graph.py/Solution.cloneGraph/original