MCPcopy Index your code
hub / github.com/loiane/javascript-datastructures-algorithms / addEdge

Method addEdge

src/13-graph/graph.js:21–32  ·  view source on GitHub ↗
(vertex, edge)

Source from the content-addressed store, hash-verified

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;

Callers 8

buildSampleGraphFunction · 0.95
02-using-bfs.tsFile · 0.45
03-using-dfs.tsFile · 0.45
03-using-dfs.jsFile · 0.45
02-using-bfs.jsFile · 0.45
graph.test.tsFile · 0.45

Calls 3

addVertexMethod · 0.95
getMethod · 0.45
pushMethod · 0.45

Tested by 1

buildSampleGraphFunction · 0.76