MCPcopy
hub / github.com/TheAlgorithms/JavaScript / addEdge

Method addEdge

Graphs/Kosaraju.js:30–40  ·  view source on GitHub ↗
(node1, node2)

Source from the content-addressed store, hash-verified

28 }
29
30 addEdge(node1, node2) {
31 // Function to add an edge (adds the node too if they are not present in the graph)
32 if (!(node1 in this.connections) || !(node1 in this.reverseConnections)) {
33 this.addNode(node1)
34 }
35 if (!(node2 in this.connections) || !(node2 in this.reverseConnections)) {
36 this.addNode(node2)
37 }
38 this.connections[node1].add(node2)
39 this.reverseConnections[node2].add(node1)
40 }
41
42 dfsTopoSort(node, visited) {
43 visited.add(node)

Callers 2

constructorMethod · 0.95
PrimMST.test.jsFile · 0.45

Calls 2

addNodeMethod · 0.95
addMethod · 0.45

Tested by

no test coverage detected