Commit 7bac59d
authored
Fix RuntimeError in bipartite-check DFS/BFS and clean up doctests
Iteration over graph mutated by defaultdict neighbours caused
RuntimeError: dictionary changed size during iteration.
– Iterate over list(graph) in both DFS and BFS helpers.
Corrected if __name__ == "__main__": typo.
Updated two doctests that now succeed after the fix.
All doctests now pass (30/30), eliminating a critical runtime failure and improving reliability of the graph algorithms.1 file changed
+5
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
20 | 19 | | |
21 | | - | |
22 | | - | |
23 | | - | |
| 20 | + | |
24 | 21 | | |
25 | 22 | | |
26 | 23 | | |
| |||
86 | 83 | | |
87 | 84 | | |
88 | 85 | | |
89 | | - | |
| 86 | + | |
90 | 87 | | |
91 | 88 | | |
92 | 89 | | |
| |||
107 | 104 | | |
108 | 105 | | |
109 | 106 | | |
110 | | - | |
111 | 107 | | |
112 | | - | |
113 | | - | |
114 | | - | |
| 108 | + | |
115 | 109 | | |
116 | 110 | | |
117 | 111 | | |
| |||
157 | 151 | | |
158 | 152 | | |
159 | 153 | | |
160 | | - | |
| 154 | + | |
161 | 155 | | |
162 | 156 | | |
163 | 157 | | |
| |||
173 | 167 | | |
174 | 168 | | |
175 | 169 | | |
176 | | - | |
| 170 | + | |
177 | 171 | | |
178 | 172 | | |
179 | 173 | | |
| |||
0 commit comments