示例#1
0
 public Dictionary<Vertex, DFSVisitingInfo> DepthFirstSearch(Vertex v)
 {
     var visits = new Dictionary<Vertex, DFSVisitingInfo>();
     visits[v] = new DFSVisitingInfo(null);
     DepthFirstSearch(v, visits);
     return visits;
 }
示例#2
0
 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;
         }
     }
 }