@@ -514,6 +514,21 @@ describe("Graph", function() {
514514 } ) ;
515515 } ) ;
516516
517+ describe ( "neighbors" , function ( ) {
518+ it ( "returns undefined for a node that is not in the graph" , function ( ) {
519+ expect ( g . neighbors ( "a" ) ) . to . be . undefined ;
520+ } ) ;
521+
522+ it ( "returns the neighbors of a node" , function ( ) {
523+ g . setEdge ( "a" , "b" ) ;
524+ g . setEdge ( "b" , "c" ) ;
525+ g . setEdge ( "a" , "a" ) ;
526+ expect ( _ . sortBy ( g . neighbors ( "a" ) ) ) . to . eql ( [ "a" , "b" ] ) ;
527+ expect ( _ . sortBy ( g . neighbors ( "b" ) ) ) . to . eql ( [ "a" , "c" ] ) ;
528+ expect ( _ . sortBy ( g . neighbors ( "c" ) ) ) . to . eql ( [ "b" ] ) ;
529+ } ) ;
530+ } ) ;
531+
517532 describe ( "isLeaf" , function ( ) {
518533 it ( "returns false for connected node in undirected graph" , function ( ) {
519534 g = new Graph ( { directed : false } ) ;
@@ -545,21 +560,6 @@ describe("Graph", function() {
545560 } ) ;
546561 } ) ;
547562
548- describe ( "neighbors" , function ( ) {
549- it ( "returns undefined for a node that is not in the graph" , function ( ) {
550- expect ( g . neighbors ( "a" ) ) . to . be . undefined ;
551- } ) ;
552-
553- it ( "returns the neighbors of a node" , function ( ) {
554- g . setEdge ( "a" , "b" ) ;
555- g . setEdge ( "b" , "c" ) ;
556- g . setEdge ( "a" , "a" ) ;
557- expect ( _ . sortBy ( g . neighbors ( "a" ) ) ) . to . eql ( [ "a" , "b" ] ) ;
558- expect ( _ . sortBy ( g . neighbors ( "b" ) ) ) . to . eql ( [ "a" , "c" ] ) ;
559- expect ( _ . sortBy ( g . neighbors ( "c" ) ) ) . to . eql ( [ "b" ] ) ;
560- } ) ;
561- } ) ;
562-
563563 describe ( "edges" , function ( ) {
564564 it ( "is empty if there are no edges in the graph" , function ( ) {
565565 expect ( g . edges ( ) ) . to . eql ( [ ] ) ;
0 commit comments