Skip to content

Re-implement getNodeLevel in NodeSecureNetwork (vis-network workspace) #613

@fraxken

Description

@fraxken

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

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;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions