示例#1
0
 public void DFSSearch(DG g, int i)
 {
     _explored[i] = true;
     foreach (int j in g._vertices[i])
     {
         if (!_explored[j])
         {
             DFSSearch(g, j);
         }
     }
     _f[i] = ++_t;
 }
示例#2
0
        public int[] DoSearch(DG g, int n)
        {
            _t        = 0;
            _f        = new int[n];
            _explored = Enumerable.Repeat(false, n + 1).ToArray();

            for (int _i = n; _i >= 1; _i--)
            {
                if (!_explored[_i])
                {
                    DFSSearch(g, _i);
                }
            }

            return(_f);
        }
示例#3
0
        public static void Main(string[] args)
        {
            var _n     = 875714;
            var _grev  = new DG(_n);
            var _lines = File.ReadAllLines("SCC.txt");

            var _tokenizer = new string[] { " ", "\t" };

            Array.ForEach(_lines, _l =>
            {
                var _tokens = _l.Split(_tokenizer, StringSplitOptions.RemoveEmptyEntries).Select(_x => int.Parse(_x)).ToArray();
                _grev.Add(_tokens[1], _tokens[0]);
            });

            var _f = new Search().DoSearch(_grev, _n);
        }