(currentNode: string)
| 42 | const visited = new Set<string>() |
| 43 | |
| 44 | function canReachSource(currentNode: string): boolean { |
| 45 | if (currentNode === sourceId) { |
| 46 | return true |
| 47 | } |
| 48 | |
| 49 | if (visited.has(currentNode)) { |
| 50 | return false |
| 51 | } |
| 52 | |
| 53 | visited.add(currentNode) |
| 54 | |
| 55 | const neighbors = adjacencyList.get(currentNode) || [] |
| 56 | for (const neighbor of neighbors) { |
| 57 | if (canReachSource(neighbor)) { |
| 58 | return true |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | return false |
| 63 | } |
| 64 | |
| 65 | return canReachSource(targetId) |
| 66 | } |
no test coverage detected