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

Method printGraph

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

Source from the content-addressed store, hash-verified

37
38 // Prints the vertex and adjacency list
39 printGraph(output = (value) => console.log(value)) {
40 // get all the vertices
41 const getKeys = this.AdjList.keys()
42
43 // iterate over the vertices
44 for (const i of getKeys) {
45 // get the corresponding adjacency list
46 // for the vertex
47 const getValues = this.AdjList.get(i)
48 let conc = ''
49
50 // iterate over the adjacency list
51 // concatenate the values into a string
52 for (const j of getValues) {
53 conc += j + ' '
54 }
55
56 // print the vertex and its adjacency list
57 output(i + ' -> ' + conc)
58 }
59 }
60}
61
62export { Graph }

Callers

nothing calls this directly

Calls 3

outputFunction · 0.85
logMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected