Re-implement getNodeLevel function at the root of main.js into the NodeSecureNetwork class (vis-network workspace).
|
function getNodeLevel(node) { |
|
const rootNode = secureDataSet.linker.get(0); |
|
if (node.id === rootNode.id) { |
|
return 0; |
|
} |
|
|
|
let level = 1; |
|
let currentNode = node; |
|
while (currentNode.usedBy[rootNode.name] === undefined) { |
|
currentNode = secureDataSet.linker.get( |
|
[...secureDataSet.linker].find(([_, { name }]) => Object.keys(currentNode.usedBy)[0] === name)[0] |
|
); |
|
level++; |
|
} |
|
|
|
return level; |
|
} |
Re-implement getNodeLevel function at the root of main.js into the NodeSecureNetwork class (vis-network workspace).
cli/public/main.js
Lines 176 to 192 in 72044e9