Beispiel #1
0
        /// <summary>
        /// Runs the RINGS algorithm on a small directory.
        /// </summary>
        /// <param name="args"></param>
        public static void t4Main(string[] args)
        {
            string t = "<drive name = \"C:\">\n" +
                       "<directory name = \"d0\"> </directory>" +
                       "<directory name = \"d0\"> </directory>" +
                       "<directory name = \"d1\">Unauthorized</directory>" +
                       "<directory name = \"d2\"><file name = \"file2\"></file><directory name = \"file3\"></directory></directory>" +
                       "</drive>";


            Tag r = XMLReaderToTree.extractTreeFromXML(XmlReader.Create(new StringReader(t)));

            printTagAndChildren(r, 0);

            Console.ReadKey();
            CircleNode layout = RINGS.MakeLayout(r, 350);

            Console.WriteLine("Circles:");
            Circle tempC;

            Console.ReadKey();
            RINGSForm f = (new RINGSForm(700, 700));

            f.Show();
            f.DrawAllCircles(layout);
            Console.ReadKey();
            //Console.WriteLine("Saving image");
            //f.Refresh();
            //f.drawToFile(@"C:\Users\Emad\Desktop\fileSystem.png");
            Console.ReadKey();
        }
Beispiel #2
0
        public static void evaluateFig2Complete()
        {
            Tag r = XMLReaderToTree.extractDirectory(
                @"C:\Users\Emad\Dropbox\DTU\Bachelor projekt\File system screenshots\RINGS-fig2-complete.xml", "");
            int drawingSize = 8000;

            Console.WriteLine("Loaded tree.");
            CircleNode layout = RINGS.MakeLayout(r, drawingSize);

            Console.WriteLine("Created layout:");
            using (System.IO.StreamWriter file =
                       new System.IO.StreamWriter(@"C:\Users\Emad\Dropbox\DTU\Bachelor projekt\Drawing algorithms\Evaluations\evaluations-Fig2Complete.txt", false))
            {
                file.WriteLine("File size\tStaticness\tValue/size distance");
                double[][] eval = evaluateLayout(layout);
                for (int i = 0; i < 6; i++)
                {
                    for (int j = 0; j < 3; j++)
                    {
                        file.Write(eval[j][i]);
                        file.Write("\t");
                    }
                    file.Write("\n");
                }
            }
            Console.Write("DONE");
            Console.ReadLine();
        }
Beispiel #3
0
        public static void calculateMutualStaticness(CircleNode[] siblings, List <int> resultStore)
        {
            RINGS.sortByNumberOfChildrenLargestFirst(siblings);

            for (int i = 1; i < siblings.Count(); i++)
            {
                resultStore.Add(siblings.ElementAt(i - 1).SourceTag.NumberOfChildren()
                                - siblings.ElementAt(i).SourceTag.NumberOfChildren());
            }

            foreach (CircleNode s in siblings)
            {
                calculateMutualStaticness((CircleNode[])s.GetChildren(), resultStore);
            }
        }
Beispiel #4
0
        public static void t6Main(String[] args)
        {
            Tag r = XMLReaderToTree.extractDirectory(
                @"C:\Users\Emad\Dropbox\DTU\Bachelor projekt\report\file-systems\many-equal-files.xml", "");

            //printTagAndChildren(r, 0);
            int drawingSize = 100;

            Console.WriteLine("Loaded tree.");
            CircleNode layout = RINGS.MakeLayout(r, drawingSize);

            Console.WriteLine("Created layout.");

            RINGSForm f = new RINGSForm(drawingSize * 2, drawingSize * 2);

            f.Show();
            f.DrawAllCircles(layout);
            f.drawToFile(@"C:\Users\Emad\Dropbox\DTU\Bachelor projekt\report\file-systems\many-equal-files" + "-master.png");
            Console.ReadLine();
        }
Beispiel #5
0
        /// <summary>
        /// Loads the system creenshot and runs the RINGS algorithm, saving the result
        /// in a PNG file.
        /// </summary>
        /// <param name="args"></param>
        public static void t5Main(string[] args)
        {
            Tag r = XMLReaderToTree.extractDirectory(
                @"C:\Users\Emad\Dropbox\DTU\Bachelor projekt\File system screenshots\FS SS 15-03-16.xml", "");

            //printTagAndChildren(r, 0);
            int drawingSize = 8000;

            Console.WriteLine("Loaded tree.");
            CircleNode layout = RINGS.MakeLayout(r, drawingSize);

            Console.WriteLine("Created layout.");

            RINGSForm f = new RINGSForm(drawingSize * 2, drawingSize * 2);

            f.Show();
            f.DrawAllCircles(layout);
            f.drawToFile(@"C:\Users\Emad\Dropbox\DTU\Bachelor projekt\File system screenshots\FS SS 15-03-16.png");
            Console.ReadLine();
        }
Beispiel #6
0
        //Helper methods
        public static void calculateDistanceBetweenRelativeValueAndSize(CircleNode[] siblings, List <double> resultStore)
        {
            //Sort by child size
            Array.Sort(siblings, delegate(CircleNode x, CircleNode y)
            {
                return(x.SourceTag.NumberOfChildren() - y.SourceTag.NumberOfChildren());
            });
            Array.Reverse(siblings);

            //Extract tags
            Tag[] siblingTags = new Tag[siblings.Count()];
            for (int i = 0; i < siblings.Count(); i++)
            {
                siblingTags[i] = siblings[i].SourceTag;
            }
            if (siblingTags.Count() != siblings.Count())
            {
                throw new EvaluationException("calculateDistancesBetweenRelativevalueAndSize: tag array not correct length");
            }

            List <int> ChildrenInLevel = new List <int>();

            int index = 0;

            while (index < siblings.Count())
            {
                double currentLevelChildRadius = siblings[index].CircleValue.Radius;
                int    currentLevelstartIndex  = index;
                int    currentLevelEndIndexExclusive;
                //Find all children in level
                for (currentLevelEndIndexExclusive = index + 1; currentLevelEndIndexExclusive < siblings.Count() && currentLevelChildRadius == siblings[currentLevelEndIndexExclusive].CircleValue.Radius; currentLevelEndIndexExclusive++)
                {
                }

                //Count children in level
                ChildrenInLevel.Add(currentLevelEndIndexExclusive - currentLevelstartIndex);

                int totalChildren = RINGS.numberOfChildren(siblingTags, 0, siblingTags.Count());

                for (int i = currentLevelstartIndex; i < currentLevelEndIndexExclusive; i++)
                {
                    int    k = ChildrenInLevel.Last();
                    double relativeValue;
                    if (totalChildren < 1)
                    {
                        relativeValue = 1.0 / (double)siblings.Count();
                    }
                    else
                    {
                        relativeValue = (double)RINGS.numberOfChildren(siblingTags, i, i + 1) / (double)totalChildren;
                    }
                    //calculate relative size

                    double relativeSize;
                    relativeSize = 1;
                    for (int j = 0; j < ChildrenInLevel.Count() - 1; j++)
                    {
                        relativeSize *= RINGS.areaLeftInCenter(
                            ChildrenInLevel.ElementAt(j));
                    }
                    if (k == 1)
                    {
                        relativeSize *= 0.9;
                    }
                    else
                    {
                        relativeSize *= (1 - RINGS.areaLeftInCenter(k)) / k;
                    }


                    if (relativeValue > relativeSize)
                    {
                        resultStore.Add(relativeValue - relativeSize);
                    }
                    else
                    {
                        resultStore.Add(relativeSize - relativeValue);
                    }
                }
                index = currentLevelEndIndexExclusive;
            }
            foreach (CircleNode s in siblings)
            {
                if (s.GetChildren().Count() > 0)
                {
                    calculateDistanceBetweenRelativeValueAndSize((CircleNode[])s.GetChildren(), resultStore);
                }
            }
        }
Beispiel #7
0
        public static void evaluateScreenshots()
        {
            string screenshotPath = @"C:\Users\Emad\Dropbox\DTU\Bachelor projekt\File system screenshots";

            string[] screenshots = new string[] {
                "FS SS 15-03-16",
                "FS SS MOM",
                "FS SS ZEINA",
                "FS SS STAT",
                "FS SS BABA"
            };

            int drawingSize = 8000;
            Tag r;

            CircleNode[] layouts     = new CircleNode[screenshots.Length];
            double[][][] evaluations = new double[screenshots.Length][][];

            for (int i = 0; i < screenshots.Length; i++)
            {
                r = XMLReaderToTree.extractDirectory(
                    screenshotPath + "\\" + screenshots[i] + ".xml", "");
                layouts[i]     = RINGS.MakeLayout(r, drawingSize);
                evaluations[i] = evaluateLayout(layouts[i]);
            }

            double[][] compiledEvaluation = new double[3][];
            for (int i = 0; i < compiledEvaluation.Length; i++)
            {
                compiledEvaluation[i] = new double[6];
            }

            for (int i = 0; i < compiledEvaluation.Length; i++)
            {
                for (int j = 0; j < compiledEvaluation[0].Length; j++)
                {
                    double sum = 0;
                    for (int k = 0; k < evaluations.Length; k++)
                    {
                        sum += evaluations[k][i][j];
                    }
                    compiledEvaluation[i][j] = sum / evaluations.Length;
                }
            }

            using (System.IO.StreamWriter file =
                       new System.IO.StreamWriter(@"C:\Users\Emad\Dropbox\DTU\Bachelor projekt\Drawing algorithms\Evaluations\evaluations-master-all.txt", false))
            {
                file.WriteLine("File size\tStaticness\tValue/size distance");
                for (int i = 0; i < compiledEvaluation[0].Length; i++)
                {
                    for (int j = 0; j < compiledEvaluation.Length; j++)
                    {
                        file.Write(compiledEvaluation[j][i]);
                        file.Write("\t");
                    }
                    file.Write("\n");
                }
            }
            Console.Write("DONE");
            Console.ReadLine();
        }