public Dictionary<Vertex, DFSVisitingInfo> DepthFirstSearch(Vertex v) { var visits = new Dictionary<Vertex, DFSVisitingInfo>(); visits[v] = new DFSVisitingInfo(null); DepthFirstSearch(v, visits); return visits; }
private void DepthFirstSearch(Vertex v, Dictionary<Vertex, DFSVisitingInfo> visits) { foreach (Edge edge in v.Edges) { Vertex vertex = edge.Opposite(v); if (!visits.ContainsKey(vertex)) { visits[vertex] = new DFSVisitingInfo(v); DepthFirstSearch(vertex, visits); visits[vertex].Color = VisitingColor.Black; } } }