(vertex, edge)
| 19 | } |
| 20 | |
| 21 | addEdge(vertex, edge) { |
| 22 | if (!this.#adjList.get(vertex)) { |
| 23 | this.addVertex(vertex); |
| 24 | } |
| 25 | if (!this.#adjList.get(edge)) { |
| 26 | this.addVertex(edge); |
| 27 | } |
| 28 | this.#adjList.get(vertex).push(edge); |
| 29 | if (!this.#isDirected) { |
| 30 | this.#adjList.get(edge).push(vertex); |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | get vertices() { |
| 35 | return this.#vertices; |