Ejemplo n.º 1
0
        public static double Difference(List <Shred> first, List <Shred> second)
        {
            var firstId  = first.Select(shred => shred.Id).ToList();
            var secondId = second.Select(shred => shred.Id).ToList();

            return(Differ.DiffShredByOrder(firstId, secondId));
        }
Ejemplo n.º 2
0
        public void DiffByShredOrderTest()
        {
            var first = new List <long> {
                0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
            };
            var second = new List <long> {
                1, 0, 3, 2, 5, 4, 7, 6, 10, 9, 8
            };
            var third = new List <long> {
                0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
            };
            var fourth = new List <long> {
                0, 1, 2, 3, 4, 5, 10, 9, 8, 7, 6
            };
            var actual   = Differ.DiffShredByOrder(first, second);
            var expected = 6.0 / 10.0;

            Assert.IsTrue(Math.Abs(actual - expected) < 0.001);
            actual   = Differ.DiffShredByOrder(first, third);
            expected = 1.0;
            Assert.IsTrue(Math.Abs(expected - actual) < 0.0001);
            actual   = Differ.DiffShredByOrder(first, fourth);
            expected = 9.0 / 10.0;
            Assert.IsTrue(Math.Abs(expected - actual) < 0.0001);
        }
Ejemplo n.º 3
0
        public void NaiveKruskalAuthentic()
        {
            var path = Path.Combine(Drive.GetDriveRoot(), Dir.PdfRequiremnetTestDirectory,
                                    Dir.PdfRequiremnetTestFullOne);
            var shreds  = Shred.Factory("image", path, false);
            var results = Reconstructor.NaiveKruskalAlgorithm(shreds);

            shreds.ForEach(shred => Console.Write(" " + shred.Id + ", "));
            Console.WriteLine();
            results.ForEach(shred => Console.Write(" " + shred.Id + ", "));
            Console.WriteLine();
            var diff = Differ.DiffShredByOrder(results.Select(shred => shred.Id).ToList(), Enumerable.Range(0, results.Count).Select(ii => (long)ii).ToList());

            Console.WriteLine("Difference : " + diff);
            ExportResult((Cluster)results.First().Root(), "../../visualizer/NaiveKruskalAuthentic.png");
        }