1.0.11 • Published 6 years ago

@coutcout/tree-datastructure v1.0.11

Weekly downloads
1
License
MIT
Repository
github
Last release
6 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

6 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago