(node1, node2)
| 27 | } |
| 28 | |
| 29 | addEdge(node1, node2) { |
| 30 | // Function to add an edge (adds the node too if they are not present in the tree) |
| 31 | if (!this.connections.has(node1)) { |
| 32 | this.addNode(node1) |
| 33 | } |
| 34 | if (!this.connections.has(node2)) { |
| 35 | this.addNode(node2) |
| 36 | } |
| 37 | this.connections.get(node1).add(node2) |
| 38 | this.connections.get(node2).add(node1) |
| 39 | } |
| 40 | |
| 41 | dfs(node, parent) { |
| 42 | // The dfs function calculates 2^i-th ancestor of all nodes for i ranging from 0 to this.log |
no test coverage detected