Movatterモバイル変換


[0]ホーム

URL:


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

Commitf7ebddc

Browse files
committed
Remove duplicated methods from Graph class.
1 parent9bc2800 commitf7ebddc

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
returnvertex.findEdge(endVertex);
124124
}
125125

126-
/**
127-
*@param {string} vertexKey
128-
*@returns {GraphVertex}
129-
*/
130-
findVertexByKey(vertexKey){
131-
if(this.vertices[vertexKey]){
132-
returnthis.vertices[vertexKey];
133-
}
134-
135-
returnnull;
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-
constgraphVertexA=graph.findVertexByKey(vertexA.getKey());
36-
constgraphVertexB=graph.findVertexByKey(vertexB.getKey());
35+
constgraphVertexA=graph.getVertexByKey(vertexA.getKey());
36+
constgraphVertexB=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-
constgraphVertexA=graph.findVertexByKey(vertexA.getKey());
64-
constgraphVertexB=graph.findVertexByKey(vertexB.getKey());
63+
constgraphVertexA=graph.getVertexByKey(vertexA.getKey());
64+
constgraphVertexB=graph.getVertexByKey(vertexB.getKey());
6565

6666
expect(graph.toString()).toBe('A,B');
6767
expect(graphVertexA).toBeDefined();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp