@dustinleethomas/structs
v2.4.2
Published
playing around with NPM and creating a simple data structure library
Downloads
17
Readme
@dthomas314/structs
structs library for npm package
(https://github.com/dthomas314/structs)
Install
$ npm install @dustinleethomas/structs
Usage
const MinHeap = require("@dustinleethomas/structs/MinHeap");
let testArray = [1, 4, 2, 7];
let myHeap = new MinHeap();
for(const elem of testArray) {
myHeap.insert(elem);
}
myHeap.print();
console.log(myHeap.remove());
myHeap.print();
console.log(myHeap.remove());
myHeap.print();
console.log(myHeap.remove());
myHeap.print();
console.log(myHeap.remove());
myHeap.print();
console.log(myHeap.remove());
myHeap.print();
const Graph = require("@dustinleethomas/structs/Graph");
let myGraph = new Graph(6);
myGraph.addVertex('A');
myGraph.addVertex('B');
myGraph.addVertex('C');
myGraph.addVertex('D');
myGraph.addVertex('E');
myGraph.addVertex('F');
myGraph.addEdge('A', 'B');
myGraph.addEdge('A', 'D');
myGraph.addEdge('A', 'E');
myGraph.addEdge('B', 'C');
myGraph.addEdge('D', 'E');
myGraph.addEdge('E', 'F');
myGraph.addEdge('E', 'C');
myGraph.addEdge('C', 'F');
myGraph.print();
console.log('BFS');
myGraph.bfs('A');
console.log('DFS');
myGraph.dfs('A');