示例#1
0
        public void TraverseGraphFromUsingDfs(SparseGraphV2 graph, int startPos)
        {
            if (startPos < 0 || startPos > graph.NumberOfVertex)
            {
                return;
            }

            Dfs(graph, startPos);
        }
示例#2
0
        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]);
                }
            }
        }
示例#3
0
 public TraverseGraphV2(SparseGraphV2 graph)
 {
     _graph = graph;
     ResetVisitedList();
 }