Skip to content

Commit f42cec0

Browse files
authored
fix(graph): enhance the judgment of boundary conditions for removeEdge functions (#1412)
1 parent 09f7223 commit f42cec0

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

codes/javascript/chapter_graph/graph_adjacency_list.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ class GraphAdjList {
4646
if (
4747
!this.adjList.has(vet1) ||
4848
!this.adjList.has(vet2) ||
49-
vet1 === vet2
49+
vet1 === vet2 ||
50+
this.adjList.get(vet1).indexOf(vet2) === -1
5051
) {
5152
throw new Error('Illegal Argument Exception');
5253
}

codes/typescript/chapter_graph/graph_adjacency_list.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ class GraphAdjList {
4646
if (
4747
!this.adjList.has(vet1) ||
4848
!this.adjList.has(vet2) ||
49-
vet1 === vet2
49+
vet1 === vet2 ||
50+
this.adjList.get(vet1).indexOf(vet2) === -1
5051
) {
5152
throw new Error('Illegal Argument Exception');
5253
}

zh-hant/codes/javascript/chapter_graph/graph_adjacency_list.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ class GraphAdjList {
4646
if (
4747
!this.adjList.has(vet1) ||
4848
!this.adjList.has(vet2) ||
49-
vet1 === vet2
49+
vet1 === vet2 ||
50+
this.adjList.get(vet1).indexOf(vet2) === -1
5051
) {
5152
throw new Error('Illegal Argument Exception');
5253
}

zh-hant/codes/typescript/chapter_graph/graph_adjacency_list.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ class GraphAdjList {
4646
if (
4747
!this.adjList.has(vet1) ||
4848
!this.adjList.has(vet2) ||
49-
vet1 === vet2
49+
vet1 === vet2 ||
50+
this.adjList.get(vet1).indexOf(vet2) === -1
5051
) {
5152
throw new Error('Illegal Argument Exception');
5253
}

0 commit comments

Comments
 (0)