File tree Expand file tree Collapse file tree 2 files changed +5
-17
lines changed
src/data-structures/graph Expand file tree Collapse file tree 2 files changed +5
-17
lines changed Original file line number Diff line number Diff line change @@ -123,18 +123,6 @@ export default class Graph {
123123 return vertex . findEdge ( endVertex ) ;
124124 }
125125
126- /**
127- * @param {string } vertexKey
128- * @returns {GraphVertex }
129- */
130- findVertexByKey ( vertexKey ) {
131- if ( this . vertices [ vertexKey ] ) {
132- return this . vertices [ vertexKey ] ;
133- }
134-
135- return null ;
136- }
137-
138126 /**
139127 * @return {number }
140128 */
Original file line number Diff line number Diff line change @@ -32,14 +32,14 @@ describe('Graph', () => {
3232 expect ( graph . getAllVertices ( ) [ 0 ] ) . toEqual ( vertexA ) ;
3333 expect ( graph . getAllVertices ( ) [ 1 ] ) . toEqual ( vertexB ) ;
3434
35- const graphVertexA = graph . findVertexByKey ( vertexA . getKey ( ) ) ;
36- const graphVertexB = graph . findVertexByKey ( vertexB . getKey ( ) ) ;
35+ const graphVertexA = graph . getVertexByKey ( vertexA . getKey ( ) ) ;
36+ const graphVertexB = graph . getVertexByKey ( vertexB . getKey ( ) ) ;
3737
3838 expect ( graph . toString ( ) ) . toBe ( 'A,B' ) ;
3939 expect ( graphVertexA ) . toBeDefined ( ) ;
4040 expect ( graphVertexB ) . toBeDefined ( ) ;
4141
42- expect ( graph . findVertexByKey ( 'not existing' ) ) . toBeNull ( ) ;
42+ expect ( graph . getVertexByKey ( 'not existing' ) ) . toBeUndefined ( ) ;
4343
4444 expect ( graphVertexA . getNeighbors ( ) . length ) . toBe ( 1 ) ;
4545 expect ( graphVertexA . getNeighbors ( ) [ 0 ] ) . toEqual ( vertexB ) ;
@@ -60,8 +60,8 @@ describe('Graph', () => {
6060
6161 graph . addEdge ( edgeAB ) ;
6262
63- const graphVertexA = graph . findVertexByKey ( vertexA . getKey ( ) ) ;
64- const graphVertexB = graph . findVertexByKey ( vertexB . getKey ( ) ) ;
63+ const graphVertexA = graph . getVertexByKey ( vertexA . getKey ( ) ) ;
64+ const graphVertexB = graph . getVertexByKey ( vertexB . getKey ( ) ) ;
6565
6666 expect ( graph . toString ( ) ) . toBe ( 'A,B' ) ;
6767 expect ( graphVertexA ) . toBeDefined ( ) ;
You can’t perform that action at this time.
0 commit comments