Advertisement
mikymaione

Alg_20160219

May 24th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.97 KB | None | 0 0
  1.  
  2.         private HashSet<Nodo> Alg_20160219(int[] A, Nodo u, Nodo v)
  3.         {
  4.             var R = new HashSet<Nodo>();
  5.  
  6.             Action<Nodo> setPercorso = null;
  7.             setPercorso = (a) =>
  8.             {
  9.                 if (a != null)
  10.                 {
  11.                     if (A.Contains(a.N) && a != v & a != u)
  12.                         R.Add(a);
  13.  
  14.                     setPercorso(a.Pred);
  15.                 }
  16.             };
  17.  
  18.             Action<Nodo> Visita = null;
  19.             Visita = (x) =>
  20.             {
  21.                 x.color = Nodo.Color.Gray;
  22.  
  23.                 if (x == v)
  24.                     setPercorso(x);
  25.  
  26.                 foreach (var y in Adj[x])
  27.                     if (y.color == Nodo.Color.White)
  28.                     {
  29.                         y.Pred = x;
  30.                         Visita(y);
  31.                     }
  32.  
  33.                 x.color = Nodo.Color.White;
  34.             };
  35.  
  36.             Visita(u);
  37.  
  38.             return R;
  39.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement