Map / Graph datastructure - create graphs, find paths, etc.
- many to one mapping and many to many
- graph data structure
- inbuilt path finders in graph
- weighted path finders
HTML
<script src="./simpleGraph.js"></script>
Set data
// myMap.set([<key1> ,<key2>,...] , <values>);
const myMap = new simpleGraph.Map();
myMap.set([1,2,3],['hello','world']); //many to one
myMap.set(['hh',4, [1,3,4]],'next'); //many to one
myMap.set('hello' , 'world'); //one to one
Get data
console.log(myMap.get(1));
// ['hello','world']
console.log(myMap.get([1,3,4]));
// 'next'
console.log(myMap.get('hello'));
// 'world'
const graph = new simpleGraph.Graph();
graph.setEdge('A', 'B')
.setEdge('A', 'C')
.setEdge('B', 'C')
.setEdge('B', 'D')
.setEdge('D', 'C')
.setEdge('C', 'A')
.setEdge('C', 'D')
.setEdge('D', 'E')
.setEdge('B', 'E')
const paths = graph.paths('B', 'E');
const shortest = graph.shortestPath('B', 'E');