Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f7ebddc

Browse files
committed
Remove duplicated methods from Graph class.
1 parent 9bc2800 commit f7ebddc

File tree

2 files changed

+5
-17
lines changed

2 files changed

+5
-17
lines changed

‎src/data-structures/graph/Graph.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff 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
*/

‎src/data-structures/graph/__test__/Graph.test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff 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();

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /