Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commitd0a1358

Browse files
committed
Add basic tests for bellman ford
1 parent28b5d0f commitd0a1358

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
varexported=
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(typeofbellmanFord).toBe('function');
11+
});
12+
13+
it('should work for an empty graph',function(){
14+
varvs=[];
15+
vare=[];
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+
varvs=[newVertex(1)];
22+
vare=[];
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+
varvs=[newVertex(1),newVertex(2),newVertex(3)];
29+
vare=[];
30+
expect(bellmanFord(vs,e,1))
31+
.toEqual({parents:{'1':null},distances:{'1':0}});
32+
});
33+
});

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp