(graph, indegree, sources, path = 0)
| 229 | }; |
| 230 | |
| 231 | const bfs = (graph, indegree, sources, path = 0) => { |
| 232 | while (!sources.isEmpty()) { |
| 233 | /* Time(N * M) */ |
| 234 | for (let level = sources.size() - 1; 0 <= level; level--) { |
| 235 | /* Time(WIDTH) */ |
| 236 | checkNeighbors( |
| 237 | graph, |
| 238 | indegree, |
| 239 | sources, |
| 240 | ); /* Space((N * M) + WIDTH) */ |
| 241 | } |
| 242 | |
| 243 | path += 1; |
| 244 | } |
| 245 | |
| 246 | return path; |
| 247 | }; |
| 248 | |
| 249 | const checkNeighbors = (graph, indegree, sources) => { |
| 250 | const [row, col] = sources.dequeue(); |
no test coverage detected