mirror of
https://github.com/trekhleb/javascript-algorithms.git
synced 2026-03-13 08:51:02 +08:00
Add graph.
This commit is contained in:
24
src/data-structures/graph/__test__/GraphEdge.test.js
Normal file
24
src/data-structures/graph/__test__/GraphEdge.test.js
Normal 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);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user