* @param {GraphVertex} newVertex * @returns {Graph}
(newVertex)
| 13 | * @returns {Graph} |
| 14 | */ |
| 15 | addVertex(newVertex) { |
| 16 | const key = newVertex.getKey(); |
| 17 | |
| 18 | if (this.vertices[key]) { |
| 19 | throw new Error('Vertex has already been added before'); |
| 20 | } |
| 21 | |
| 22 | this.vertices[key] = newVertex; |
| 23 | |
| 24 | return this; |
| 25 | } |
| 26 | |
| 27 | /** |
| 28 | * @param {string} vertexKey |