{
  "name": "quixbugs-python-breadth_first_search",
  "description": "Fix bug in: breadth first search",
  "dataset": "quixbugs",
  "instruction": "There is a Python file called breadth_first_search.py in the current directory. It also uses a Node class from node.py. The breadth first search implementation has a bug. Find and fix the bug. The fix should be minimal - typically a single line change. Do not rewrite the entire function. Do not modify node.py.",
  "setup_files": {
    "breadth_first_search.py": "\nfrom collections import deque as Queue\n\ndef breadth_first_search(startnode, goalnode):\n    queue = Queue()\n    queue.append(startnode)\n\n    nodesseen = set()\n    nodesseen.add(startnode)\n\n    while True:\n        node = queue.popleft()\n\n        if node is goalnode:\n            return True\n        else:\n            queue.extend(node for node in node.successors if node not in nodesseen)\n            nodesseen.update(node.successors)\n\n    return False\n\n\n\n\"\"\"\nBreadth-First Search\n\n\nInput:\n    startnode: A digraph node\n    goalnode: A digraph node\n\nOutput:\n    Whether goalnode is reachable from startnode\n\"\"\"\n",
    "node.py": "class Node:\n    def __init__(self, value=None, successor=None, successors=[], predecessors=[], incoming_nodes=[], outgoing_nodes=[]):\n        self.value = value\n        self.successor = successor\n        self.successors = successors\n        self.predecessors = predecessors\n        self.incoming_nodes = incoming_nodes\n        self.outgoing_nodes = outgoing_nodes\n\n    def successor(self):\n        return self.successor\n\n    def successors(self):\n        return self.successors\n\n    def predecessors(self):\n        return self.predecessors\n",
    "test_breadth_first_search.py": "from node import Node\nfrom breadth_first_search import breadth_first_search\nimport sys\n\npassed = 0\nfailed = 0\n\n# Case 1: Strongly connected graph - should find path\nstation1 = Node(\"Westminster\")\nstation2 = Node(\"Waterloo\", None, [station1])\nstation3 = Node(\"Trafalgar Square\", None, [station1, station2])\nstation4 = Node(\"Canary Wharf\", None, [station2, station3])\nstation5 = Node(\"London Bridge\", None, [station4, station3])\nstation6 = Node(\"Tottenham Court Road\", None, [station5, station4])\nresult = breadth_first_search(station6, station1)\nif result == True: passed += 1\nelse: print(f\"FAIL case 1: expected True, got {result}\"); failed += 1\n\n# Case 2: Branching graph - should find path\nnodef = Node(\"F\")\nnodee = Node(\"E\")\nnoded = Node(\"D\")\nnodec = Node(\"C\", None, [nodef])\nnodeb = Node(\"B\", None, [nodee])\nnodea = Node(\"A\", None, [nodeb, nodec, noded])\nresult = breadth_first_search(nodea, nodee)\nif result == True: passed += 1\nelse: print(f\"FAIL case 2: expected True, got {result}\"); failed += 1\n\n# Case 3: Unconnected nodes - should not find path\nresult = breadth_first_search(nodef, nodee)\nif result == False: passed += 1\nelse: print(f\"FAIL case 3: expected False, got {result}\"); failed += 1\n\n# Case 4: Same node - should find path\nresult = breadth_first_search(nodef, nodef)\nif result == True: passed += 1\nelse: print(f\"FAIL case 4: expected True, got {result}\"); failed += 1\n\nprint(f\"{passed}/{passed+failed} tests passed\")\nif failed > 0: sys.exit(1)\n"
  },
  "verify": "cd $BENCH_WORK_DIR && python3 test_breadth_first_search.py",
  "timeout": 180000,
  "tags": [
    "quixbugs",
    "python",
    "bug-fix",
    "graph"
  ]
}