* @param {GraphEdge} edge
(edge)
| 99 | * @param {GraphEdge} edge |
| 100 | */ |
| 101 | deleteEdge(edge) { |
| 102 | // Delete edge from the list of edges. |
| 103 | if (this.edges[edge.getKey()]) { |
| 104 | delete this.edges[edge.getKey()]; |
| 105 | } else { |
| 106 | throw new Error('Edge not found in graph'); |
| 107 | } |
| 108 | |
| 109 | // Try to find and end start vertices and delete edge from them. |
| 110 | const startVertex = this.getVertexByKey(edge.startVertex.getKey()); |
| 111 | const endVertex = this.getVertexByKey(edge.endVertex.getKey()); |
| 112 | |
| 113 | startVertex.deleteEdge(edge); |
| 114 | endVertex.deleteEdge(edge); |
| 115 | } |
| 116 | |
| 117 | /** |
| 118 | * @param {GraphVertex} startVertex |