0.1.1 • Published 6 years ago
ss-graph v0.1.1
ss-graph
Data Structure Serial - Graph
- written in Typescript
- fully tested
Installation
Node.js / Browserify
npm install ss-graph --savevar {Graph, GraphEdge, GraphVertex} = require('ss-graph');Global object
Include the pre-built script.
<script src="./dist/index.umd.min.js"></script>usage
const graph = new Graph();
const vertexA = new GraphVertex('A');
const vertexB = new GraphVertex('B');
const vertexC = new GraphVertex('C');
const vertexD = new GraphVertex('D');
const edgeAB = new GraphEdge(vertexA, vertexB, 1);
const edgeBC = new GraphEdge(vertexB, vertexC, 2);
const edgeCD = new GraphEdge(vertexC, vertexD, 3);
const edgeAD = new GraphEdge(vertexA, vertexD, 4);
graph
.addEdge(edgeAB)
.addEdge(edgeBC)
.addEdge(edgeCD)
.addEdge(edgeAD);
expect(graph.getWeight()).toBe(10);Build & test
npm run buildnpm testdocument
npm run docthen open the generated out/index.html file in your browser.
License
MIT.