File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11node_modules
22package-lock.json
3+ * .swp
Original file line number Diff line number Diff line change @@ -88,6 +88,7 @@ module.exports = function Graph(serialized){
8888 // Sets the weight of the given edge.
8989 function setEdgeWeight ( u , v , weight ) {
9090 edgeWeights [ encodeEdge ( u , v ) ] = weight ;
91+ return graph ;
9192 }
9293
9394 // Gets the weight of the given edge.
Original file line number Diff line number Diff line change @@ -313,10 +313,24 @@ describe("Graph", function() {
313313 } ) ;
314314
315315 describe ( "Edge Weights" , function ( ) {
316+
316317 it ( "Should set and get an edge weight." , function ( ) {
317318 var graph = Graph ( ) . addEdge ( "a" , "b" , 5 ) ;
318319 assert . equal ( graph . getEdgeWeight ( "a" , "b" ) , 5 ) ;
319320 } ) ;
321+
322+ it ( "Should set edge weight via setEdgeWeight." , function ( ) {
323+ var graph = Graph ( )
324+ . addEdge ( "a" , "b" )
325+ . setEdgeWeight ( "a" , "b" , 5 ) ;
326+ assert . equal ( graph . getEdgeWeight ( "a" , "b" ) , 5 ) ;
327+ } ) ;
328+
329+ it ( "Should return weight of 1 if no weight set." , function ( ) {
330+ var graph = Graph ( ) . addEdge ( "a" , "b" ) ;
331+ assert . equal ( graph . getEdgeWeight ( "a" , "b" ) , 1 ) ;
332+ } ) ;
333+
320334 } ) ;
321335} ) ;
322336
You can’t perform that action at this time.
0 commit comments