It's exactly a DFS copy, and comparing with BFS version, it looks concise.

Here are my BFS copy.

UndirectedGraphNode *cloneGraph(UndirectedGraphNode *node) {
// BFS copy.
if (node == nullptr) {
return nullptr;
}
queue<UndirectedGraphNode *> BFSQueue;
BFSQueue.push(node);
unordered_map<int, UndirectedGraphNode *> visited;
// Copy the first node.
UndirectedGraphNode *copy = new UndirectedGraphNode(node->label);
// Mark as visited.
visited[node->label] = copy;
while (!BFSQueue.empty()) {
UndirectedGraphNode *oNode = BFSQueue.front();
BFSQueue.pop();
// Copy the list of its neighbors.
vector<UndirectedGraphNode *> oNeighbors = oNode->neighbors;
for (vector<UndirectedGraphNode *>::const_iterator it = oNeighbors.begin(); it != oNeighbors.end(); ++it) {
if (visited.count((*it)->label) == 0) {
UndirectedGraphNode *neighborNode = new UndirectedGraphNode((*it)->label);
visited[(*it)->label] = neighborNode;
BFSQueue.push(*it);
}
(visited[oNode->label]->neighbors).push_back(visited[(*it)->label]);
}
}
return copy;
}