Add graph.

This commit is contained in:
Oleksii Trekhleb
2018-04-10 11:42:32 +03:00
parent 840635e613
commit 67cdad8030
8 changed files with 426 additions and 1 deletions

View File

@@ -0,0 +1,24 @@
import GraphEdge from '../GraphEdge';
import GraphVertex from '../GraphVertex';
describe('GraphEdge', () => {
it('should create graph edge with default weight', () => {
const startVertex = new GraphVertex('A');
const endVertex = new GraphVertex('B');
const edge = new GraphEdge(startVertex, endVertex);
expect(edge.startVertex).toEqual(startVertex);
expect(edge.endVertex).toEqual(endVertex);
expect(edge.weight).toEqual(1);
});
it('should create graph edge with predefined weight', () => {
const startVertex = new GraphVertex('A');
const endVertex = new GraphVertex('B');
const edge = new GraphEdge(startVertex, endVertex, 10);
expect(edge.startVertex).toEqual(startVertex);
expect(edge.endVertex).toEqual(endVertex);
expect(edge.weight).toEqual(10);
});
});