File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed
test/graphs/shortest-path Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change 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+ } ) ;
You can’t perform that action at this time.
0 commit comments