File tree 2 files changed +5
-17
lines changed
src/data-structures/graph
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 {
123
123
return vertex . findEdge ( endVertex ) ;
124
124
}
125
125
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
-
138
126
/**
139
127
* @return {number }
140
128
*/
Original file line number Diff line number Diff line change @@ -32,14 +32,14 @@ describe('Graph', () => {
32
32
expect ( graph . getAllVertices ( ) [ 0 ] ) . toEqual ( vertexA ) ;
33
33
expect ( graph . getAllVertices ( ) [ 1 ] ) . toEqual ( vertexB ) ;
34
34
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 ( ) ) ;
37
37
38
38
expect ( graph . toString ( ) ) . toBe ( 'A,B' ) ;
39
39
expect ( graphVertexA ) . toBeDefined ( ) ;
40
40
expect ( graphVertexB ) . toBeDefined ( ) ;
41
41
42
- expect ( graph . findVertexByKey ( 'not existing' ) ) . toBeNull ( ) ;
42
+ expect ( graph . getVertexByKey ( 'not existing' ) ) . toBeUndefined ( ) ;
43
43
44
44
expect ( graphVertexA . getNeighbors ( ) . length ) . toBe ( 1 ) ;
45
45
expect ( graphVertexA . getNeighbors ( ) [ 0 ] ) . toEqual ( vertexB ) ;
@@ -60,8 +60,8 @@ describe('Graph', () => {
60
60
61
61
graph . addEdge ( edgeAB ) ;
62
62
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 ( ) ) ;
65
65
66
66
expect ( graph . toString ( ) ) . toBe ( 'A,B' ) ;
67
67
expect ( graphVertexA ) . toBeDefined ( ) ;
You can’t perform that action at this time.
0 commit comments