Gathering detailed insights and metrics for bfs-tree-layout
Gathering detailed insights and metrics for bfs-tree-layout
Gathering detailed insights and metrics for bfs-tree-layout
Gathering detailed insights and metrics for bfs-tree-layout
npm install bfs-tree-layout
Typescript
Module System
NPM Version
69
Supply Chain
94.6
Quality
75
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
5 Stars
10 Commits
4 Forks
2 Watchers
1 Branches
1 Contributors
Updated on Jun 14, 2021
Latest Version
0.0.4
Package Id
bfs-tree-layout@0.0.4
Size
2.17 kB
NPM Version
1.2.17
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
2
Operations on nodes for balanced binary trees stored in bfs layout. These are useful if you are building data structures, like binary search trees, implicitly (ie not storing pointers to subtrees).
BFS layout, unlike inorder layout, is much faster for performing binary searches and bounds queries. The disadvantage is that it is much slower at inorder traversal.
npm install inorder-tree-layout
Assume that the tree is filled in level order, and laid out in memory via an bfs traversal. For example:
The tree:
0
/ \
1 2
/ \ / \
3 4 5 6
/ \ |
7 8 9
With this picture in mind, here are some operations:
1var layout = require("bfs-tree-layout") 2 3console.log(layout.left(10, 3)) //Prints: 7 4 5console.log(layout.parent(10, 4)) //Prints: 1 6 7console.log(layout.height(10, 2)) //Prints: 1 8
1var layout = require("bfs-tree-layout")
Conventions:
n
is always the size of the treex
is the index of a node in the treelayout.root(n)
Returns the index of the root of a tree of size n.
layout.begin(n)
Returns the index of the first node of the tree
layout.end(n)
Returns the index of the last node in the tree
layout.height(n, x)
Returns the height of node x
in a tree of size n
layout.prev(n, x)
Returns the predecessor of x
in an in-order traversal
layout.next(n, x)
Returns the successor of x
in an in-order traversal
layout.parent(n, x)
Returns the parent of x
in a tree of size n
layout.left(n, x)
Returns the left child of x
layout.right(n, x)
Returns the right child of x
(c) 2013 Mikola Lysenko. MIT License
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
Found 0/10 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More