Code giving runtime error


#1

Why this code gives runtime error?

UndirectedGraphNode *Solution::cloneGraph(UndirectedGraphNode *node) {
    if (!node) return node;
    
  UndirectedGraphNode *nodes[100005] = {};
  bool done[100005] = {};

  queue<UndirectedGraphNode *> q;

  q.push(node);
  nodes[node->label] = new UndirectedGraphNode(node->label);

  while (q.size())
  {
    auto current = q.front();
    q.pop();

    if (done[current->label])
      continue;

    done[current->label] = true;

    auto duplicate = nodes[current->label];

    for (auto neighbour : current->neighbors)
    {
      if (!nodes[neighbour->label])
        nodes[neighbour->label] = new UndirectedGraphNode(neighbour->label);

      duplicate->neighbors.push_back(nodes[neighbour->label]);
      q.push(neighbour);
    }
  }
  
  return nodes[node->label];
}