Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d0a1358

Browse filesBrowse files
committed
Add basic tests for bellman ford
1 parent 28b5d0f commit d0a1358
Copy full SHA for d0a1358

1 file changed

+33Lines changed: 33 additions & 0 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file
+33Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
var exported =
2+
require('../../../src/graphs/shortest-path/bellman-ford'),
3+
bellmanFord = exported.bellmanFord,
4+
Vertex = exported.Vertex,
5+
Edge = exported.Edge;
6+
7+
describe('Bellman-Ford', function () {
8+
'use strict';
9+
it('should exports a method called bellmanFord', function () {
10+
expect(typeof bellmanFord).toBe('function');
11+
});
12+
13+
it('should work for an empty graph', function () {
14+
var vs = [];
15+
var e = [];
16+
expect(bellmanFord(vs, e, undefined))
17+
.toEqual({ parents: {}, distances: { undefined: 0 } });
18+
});
19+
20+
it('should work for a graph with a single vertex', function () {
21+
var vs = [new Vertex(1)];
22+
var e = [];
23+
expect(bellmanFord(vs, e, 1))
24+
.toEqual({ parents: { '1': null }, distances: { '1': 0 }});
25+
});
26+
27+
it('should work in the general case', function () {
28+
var vs = [new Vertex(1), new Vertex(2), new Vertex(3)];
29+
var e = [];
30+
expect(bellmanFord(vs, e, 1))
31+
.toEqual({ parents: { '1': null }, distances: { '1': 0 }});
32+
});
33+
});

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.