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

Method printGraph

Data-Structures/Graph/Graph.js:21–31  ·  view source on GitHub ↗
(output = (value) => console.log(value))

Source from the content-addressed store, hash-verified

19 }
20
21 printGraph(output = (value) => console.log(value)) {
22 const keys = Object.keys(this.adjacencyMap)
23 for (const i of keys) {
24 const values = this.adjacencyMap[i]
25 let vertex = ''
26 for (const j of values) {
27 vertex += j + ' '
28 }
29 output(i + ' -> ' + vertex)
30 }
31 }
32
33 /**
34 * Prints the Breadth first traversal of the graph from source.

Callers 1

Graph2.test.jsFile · 0.45

Calls 2

outputFunction · 0.85
logMethod · 0.45

Tested by

no test coverage detected