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

Function depthFirstSearch

src/13-graph/dfs.js:17–27  ·  view source on GitHub ↗
(graph, callback)

Source from the content-addressed store, hash-verified

15}
16
17const depthFirstSearch = (graph, callback) => {
18 const vertices = graph.vertices;
19 const adjList = graph.adjList;
20 const color = initializeColor(vertices);
21
22 for (let i = 0; i < vertices.length; i++) {
23 if (color[vertices[i]] === Colors.WHITE) {
24 depthFirstSearchVisit(vertices[i], color, adjList, callback);
25 }
26 }
27}
28
29const depthFirstSearchVisit = (vertex, color, adjList, callback) => {
30 color[vertex] = Colors.GREY; // Mark as discovered

Callers 3

03-using-dfs.tsFile · 0.90
graph.test.tsFile · 0.90
03-using-dfs.jsFile · 0.70

Calls 2

initializeColorFunction · 0.70
depthFirstSearchVisitFunction · 0.70

Tested by

no test coverage detected