Exemplo n.º 1
0
 public void Test01NonGeneric()
 {
     for (var i = 1; i <= ElementsNumber; i += 1 + i / (10 + _random.Next(0, 10)))
     {
         //Console.WriteLine($"i = {i}");
         var djs = new DisjointSets(ElementsNumber);
         foreach (var el in RandomShuffle(_seq))
         {
             djs.Union(el, el % i);
         }
         VerifySets(djs, i);
     }
 }
Exemplo n.º 2
0
 public void Test02Generic()
 {
     for (var i = 1; i <= ElementsNumber; i += 1 + i / (10 + _random.Next(0, 10)))
     {
         //Console.WriteLine($"i = {i}");
         var rs  = RandomShuffle(_seq).ToList();
         var djs = new DisjointSets <int>(rs);
         foreach (var el in rs)
         {
             djs.Union(el, el % i);
         }
         VerifySets(djs, i);
         for (var j = 0; j < ElementsNumber; ++j)
         {
             Assert.That(djs[j], Is.EqualTo(rs[j]));
         }
     }
 }