MCPcopy
hub / github.com/TheAlgorithms/JavaScript / constructor

Method constructor

Graphs/BinaryLifting.js:13–22  ·  view source on GitHub ↗
(root, tree)

Source from the content-addressed store, hash-verified

11
12export class BinaryLifting {
13 constructor(root, tree) {
14 this.root = root
15 this.connections = new Map()
16 this.up = new Map() // up[node][i] stores the 2^i-th parent of node
17 for (const [i, j] of tree) {
18 this.addEdge(i, j)
19 }
20 this.log = Math.ceil(Math.log2(this.connections.size))
21 this.dfs(root, root)
22 }
23
24 addNode(node) {
25 // Function to add a node to the tree (connection represented by set)

Callers

nothing calls this directly

Calls 2

addEdgeMethod · 0.95
dfsMethod · 0.95

Tested by

no test coverage detected