This is my code to run DFS on javascript, I searched and try to use setTimeout to delay each draw for 3 seconds but it won't work. Can someone show me the way to do it?
function DFSWithDirectedGraph(v) {
Nodes[v].visited = true;
reDrawNode(Nodes[v].x, Nodes[v].y, Nodes[v].id, 'blue');
for(var j = 0; j<i; j++) {
if(Path[v][j] != undefined && Nodes[j].visited == false) {
drawArrow(Nodes[v].x, Nodes[v].y, Nodes[j].x, Nodes[j].y, 'blue', Path[v][j]);
DFSWithDirectedGraph(j);
if(Path[j][v] != undefined) {
drawArrow(Nodes[j].x, Nodes[j].y, Nodes[v].x, Nodes[v].y, 'green', Path[j][v]);
} else {
drawArrow(Nodes[j].x, Nodes[j].y, Nodes[v].x, Nodes[v].y, 'green', "");
}
}
}
}