(node, parent)
| 17 | } |
| 18 | |
| 19 | dfsDepth(node, parent) { |
| 20 | // DFS to find depth of every node in the tree |
| 21 | for (const child of this.connections.get(node)) { |
| 22 | if (child !== parent) { |
| 23 | this.depth.set(child, this.depth.get(node) + 1) |
| 24 | this.dfsDepth(child, node) |
| 25 | } |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | getLCA(node1, node2) { |
| 30 | // We make sure that node1 is the deeper node among node1 and node2 |
no test coverage detected