public void TraverseGraphFromUsingDfs(SparseGraphV2 graph, int startPos) { if (startPos < 0 || startPos > graph.NumberOfVertex) { return; } Dfs(graph, startPos); }
private void Dfs(SparseGraphV2 g, int p) { Console.Write(p + ","); _visitedList[p] = true; var children = g.GetVertexes(p); for (int i = 0; i < children.Count; i++) { if (!_visitedList[children[i]]) { Dfs(g, children[i]); } } }
public TraverseGraphV2(SparseGraphV2 graph) { _graph = graph; ResetVisitedList(); }