diff --git a/src/data-structures/graph/Graph.js b/src/data-structures/graph/Graph.js index ae123ca1..ba0b6d01 100644 --- a/src/data-structures/graph/Graph.js +++ b/src/data-structures/graph/Graph.js @@ -123,18 +123,6 @@ export default class Graph { return vertex.findEdge(endVertex); } - /** - * @param {string} vertexKey - * @returns {GraphVertex} - */ - findVertexByKey(vertexKey) { - if (this.vertices[vertexKey]) { - return this.vertices[vertexKey]; - } - - return null; - } - /** * @return {number} */ diff --git a/src/data-structures/graph/__test__/Graph.test.js b/src/data-structures/graph/__test__/Graph.test.js index be6e9d7f..936a69b8 100644 --- a/src/data-structures/graph/__test__/Graph.test.js +++ b/src/data-structures/graph/__test__/Graph.test.js @@ -32,14 +32,14 @@ describe('Graph', () => { expect(graph.getAllVertices()[0]).toEqual(vertexA); expect(graph.getAllVertices()[1]).toEqual(vertexB); - const graphVertexA = graph.findVertexByKey(vertexA.getKey()); - const graphVertexB = graph.findVertexByKey(vertexB.getKey()); + const graphVertexA = graph.getVertexByKey(vertexA.getKey()); + const graphVertexB = graph.getVertexByKey(vertexB.getKey()); expect(graph.toString()).toBe('A,B'); expect(graphVertexA).toBeDefined(); expect(graphVertexB).toBeDefined(); - expect(graph.findVertexByKey('not existing')).toBeNull(); + expect(graph.getVertexByKey('not existing')).toBeUndefined(); expect(graphVertexA.getNeighbors().length).toBe(1); expect(graphVertexA.getNeighbors()[0]).toEqual(vertexB); @@ -60,8 +60,8 @@ describe('Graph', () => { graph.addEdge(edgeAB); - const graphVertexA = graph.findVertexByKey(vertexA.getKey()); - const graphVertexB = graph.findVertexByKey(vertexB.getKey()); + const graphVertexA = graph.getVertexByKey(vertexA.getKey()); + const graphVertexB = graph.getVertexByKey(vertexB.getKey()); expect(graph.toString()).toBe('A,B'); expect(graphVertexA).toBeDefined();