diff --git a/codes/javascript/chapter_graph/graph_adjacency_list.js b/codes/javascript/chapter_graph/graph_adjacency_list.js index ec7567c3c..f3daaeb17 100644 --- a/codes/javascript/chapter_graph/graph_adjacency_list.js +++ b/codes/javascript/chapter_graph/graph_adjacency_list.js @@ -46,7 +46,8 @@ class GraphAdjList { if ( !this.adjList.has(vet1) || !this.adjList.has(vet2) || - vet1 === vet2 + vet1 === vet2 || + this.adjList.get(vet1).indexOf(vet2) === -1 ) { throw new Error('Illegal Argument Exception'); } diff --git a/codes/typescript/chapter_graph/graph_adjacency_list.ts b/codes/typescript/chapter_graph/graph_adjacency_list.ts index 4c7692312..c928e72e4 100644 --- a/codes/typescript/chapter_graph/graph_adjacency_list.ts +++ b/codes/typescript/chapter_graph/graph_adjacency_list.ts @@ -46,7 +46,8 @@ class GraphAdjList { if ( !this.adjList.has(vet1) || !this.adjList.has(vet2) || - vet1 === vet2 + vet1 === vet2 || + this.adjList.get(vet1).indexOf(vet2) === -1 ) { throw new Error('Illegal Argument Exception'); } diff --git a/zh-hant/codes/javascript/chapter_graph/graph_adjacency_list.js b/zh-hant/codes/javascript/chapter_graph/graph_adjacency_list.js index 6b7ff8c71..6e50bad47 100644 --- a/zh-hant/codes/javascript/chapter_graph/graph_adjacency_list.js +++ b/zh-hant/codes/javascript/chapter_graph/graph_adjacency_list.js @@ -46,7 +46,8 @@ class GraphAdjList { if ( !this.adjList.has(vet1) || !this.adjList.has(vet2) || - vet1 === vet2 + vet1 === vet2 || + this.adjList.get(vet1).indexOf(vet2) === -1 ) { throw new Error('Illegal Argument Exception'); } diff --git a/zh-hant/codes/typescript/chapter_graph/graph_adjacency_list.ts b/zh-hant/codes/typescript/chapter_graph/graph_adjacency_list.ts index 13c76a1e5..bd137fd84 100644 --- a/zh-hant/codes/typescript/chapter_graph/graph_adjacency_list.ts +++ b/zh-hant/codes/typescript/chapter_graph/graph_adjacency_list.ts @@ -46,7 +46,8 @@ class GraphAdjList { if ( !this.adjList.has(vet1) || !this.adjList.has(vet2) || - vet1 === vet2 + vet1 === vet2 || + this.adjList.get(vet1).indexOf(vet2) === -1 ) { throw new Error('Illegal Argument Exception'); }