@coutcout/tree-datastructure
TypeScript icon, indicating that this package has built-in type declarations

1.0.11 • Public • Published

tree-datastructure

npm NPM Build Status

This package allow creating simple tree datastructures.

Installation

npm install @coutcout/tree-datastructure

Use

Create a tree

let tree = new Tree("This is the root");

Get the root

let root = tree.getRoot();

Add a node to the tree

let node1 = root.addChild("I'm the first childNode");
let node11 = node1.addChild("Hi");
let node2 = root.addChild("I'm the second child");

let node3 = new TreeNode("Bye bye");
root.addChildTreeNode(node3);

Result

digraph G {
    root -> node1
    root -> node2
    root -> node3
    node1 -> node11
}

Get a parent

let parent1 = node11.getParent(1);
// parent = root

let parent2 = node11.getParent();
// parent = node1

Get childs

let childs = root.getChilds();
// childs = [node1, node2, node3]

Package Sidebar

Install

npm i @coutcout/tree-datastructure

Weekly Downloads

113

Version

1.0.11

License

MIT

Unpacked Size

18.2 kB

Total Files

20

Last publish

Collaborators

  • coutcout