1.0.11 • Published 5 years ago

@coutcout/tree-datastructure v1.0.11

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

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]
1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago