コード例 #1
0
 public void A_list_with_two_points_returns_them_as_closest()
 {
     var points = CreatePoints(2).ToList();
     Segment closest = new ClosestPointSolver().Closest_BruteForce(points);
     Assert.Equal(closest.P1, points[0]);
     Assert.Equal(closest.P2, points[1]);
 }
コード例 #2
0
 public void a_list_with_1000_points_finds_the_closest()
 {
     var points = CreatePoints(1000).ToList();
     var expected = new Segment(new PointF(0.7874735f, 0.9796776f), new PointF(0.786889f, 0.980248451f));
     Segment closest = new ClosestPointSolver().Closest_BruteForce(points);
     Assert.Equal(expected, closest);
 }
コード例 #3
0
 public void Brute_force_attack_returns_identical_results_to_divide_and_conquer()
 {
     var points = CreatePoints(1000).ToList();
     ClosestPointSolver solver = new ClosestPointSolver();
     Segment force = solver.Closest_BruteForce(points);
     Segment DAndC = solver.Closest_Recursive(points);
     Assert.Equal(force.Length(), DAndC.Length());
 }
コード例 #4
0
        public void Brute_force_attack_returns_identical_results_to_FortuneHopcroft_attack()
        {
            var randomizer = new Random(10);
            var points = Enumerable.Range(0, 1000).Select(i => (float)randomizer.NextDouble()).ToList();
            ClosestPointSolver solver = new ClosestPointSolver();

            var p = solver.ClosestFloats_BruteForce(points);
            var q = solver.ClosestFloats(points);
            Assert.Equal(Math.Abs(p.X - p.Y), Math.Abs(q.X - q.Y));
        }