Example #1
0
        public static double[] distanceBetweenRelativeValueAndSizeMedian(CircleNode layout)
        {
            List <double> distances = new List <double>();

            if (layout.GetChildren().Count() > 0)
            {
                calculateDistanceBetweenRelativeValueAndSize((CircleNode[])layout.GetChildren(), distances);
            }
            else
            {
                return(null);
            }
            distances.Sort();
            double sum = 0;

            for (int i = 0; i < distances.Count(); i++)
            {
                sum += distances.ElementAt(i);
            }

            return(new double[] {
                distances.ElementAt(0),
                distances.ElementAt(distances.Count() / 4),
                distances.ElementAt(distances.Count() / 2),
                distances.ElementAt((int)(distances.Count() * 0.75)),
                distances.ElementAt(distances.Count() - 1),
                sum / distances.Count()
            });
        }
Example #2
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();
        }
Example #3
0
        public static double[] getEvaluationStaticness(CircleNode layout)
        {
            List <int> nodeStaticness = new List <int>();

            if (layout.GetChildren().Count() > 0)
            {
                calculateMutualStaticness((CircleNode[])layout.GetChildren(), nodeStaticness);
            }
            else
            {
                return(null);
            }
            nodeStaticness.Sort();

            double sum = 0;

            foreach (int t in nodeStaticness)
            {
                sum += t;
            }

            return(new double[] {
                nodeStaticness.ElementAt(0),
                nodeStaticness.ElementAt(nodeStaticness.Count() / 4),
                nodeStaticness.ElementAt(nodeStaticness.Count() / 2),
                nodeStaticness.ElementAt((int)(nodeStaticness.Count() * 0.75)),
                nodeStaticness.ElementAt(nodeStaticness.Count() - 1),
                sum / nodeStaticness.Count()
            });
        }
Example #4
0
        //Evaluations

        public static double[] getEvaluationFileRadius(CircleNode layout)
        {
            List <double> fileSizes = new List <double>();
            List <int>    depths    = new List <int>();

            addFilesToList(layout, fileSizes, depths, 0);

            if (fileSizes.Count() != depths.Count())
            {
                throw new EvaluationException("File sizes and depths dont sync");
            }

            fileSizes.Sort();

            double sizeSum = 0;

            for (int i = 0; i < fileSizes.Count(); i++)
            {
                sizeSum += fileSizes.ElementAt(i);
            }

            return(new double[] {
                fileSizes.ElementAt(0),
                fileSizes.ElementAt(fileSizes.Count() / 4),
                fileSizes.ElementAt(fileSizes.Count() / 2),
                fileSizes.ElementAt((int)(fileSizes.Count() * 0.75)),
                fileSizes.ElementAt(fileSizes.Count() - 1),
                sizeSum / fileSizes.Count()
            });
        }
Example #5
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();
        }
Example #6
0
        /// <summary>
        /// Recursively draws the given circle onto the given graphics in the given color.
        ///
        /// </summary>
        /// <param name="node"></param>
        /// <param name="graphics"></param>
        /// <param name="color"></param>
        public void DrawCircle(CircleNode node, System.Drawing.Graphics graphics, System.Drawing.Pen color)
        {
            Console.WriteLine("Drawing Progress: " + (drawn++ *100) / maxDraw);
            System.Drawing.Rectangle tempRec;
            Circle c = node.CircleValue;

            //Console.WriteLine("Drawing circle: " + c);
            tempRec = new System.Drawing.Rectangle(
                (int)(c.CenterX - c.Radius), (int)(c.CenterY - c.Radius),
                2 * (int)(c.Radius), 2 * (int)(c.Radius));
            graphics.DrawEllipse(color, tempRec);

            Pen colorToUse = (color == Pens.Red) ? Pens.Blue : Pens.Red;

            foreach (CircleNode n in node.GetChildren())
            {
                Tag    sourceTag = n.SourceTag;
                string type;
                sourceTag.Properties.TryGetValue("type", out type);

                if (!type.Equals("file"))
                {
                    DrawCircle(n, graphics, colorToUse);
                }
                else
                {
                    tempRec = new System.Drawing.Rectangle(
                        (int)(n.CircleValue.CenterX - n.CircleValue.Radius),
                        (int)(n.CircleValue.CenterY - n.CircleValue.Radius),
                        2 * (int)(n.CircleValue.Radius), 2 * (int)(n.CircleValue.Radius));
                    graphics.FillEllipse(new SolidBrush(colorToUse.Color), tempRec);
                }
            }
        }
Example #7
0
 /// <summary>
 /// Draws all the given circles onto the window.
 /// Additionally draws lines between a node and its children.
 /// </summary>
 /// <param name="node"></param>
 public void DrawAllCircles(CircleNode node)
 {
     using (Graphics g = Graphics.FromImage(this.bitmap))
     {
         DrawCircle(node, g, Pens.Red);
     }
     this.CreateGraphics().DrawImage(bitmap, Point.Empty);
 }
Example #8
0
        /// <summary>
        /// Returns the evaluation results of the given layout.
        /// The results are formatted as follows:
        /// results[0] is file size results
        /// results[1] is staticness results
        /// results[3] is value/size distance results
        /// results[x][0] is the minimum
        /// results[x][1] is the first quantile (25%)
        /// results[x][2] is the second quantile (50% or median)
        /// results[x][3] is the third quantile (75%)
        /// results[x][4] is the maximum
        /// results[x][5] is the average
        /// </summary>
        /// <param name="layout"></param>
        /// <returns></returns>
        public static double[][] evaluateLayout(CircleNode layout)
        {
            double[] fileSizeQuantiles = Evaluations.getEvaluationFileRadius(layout);

            double[] staticnessQuantiles = Evaluations.getEvaluationStaticness(layout);

            double[] valueSizeDistancesQuantiles = Evaluations.distanceBetweenRelativeValueAndSizeMedian(layout);

            return(new double[][] { fileSizeQuantiles, staticnessQuantiles, valueSizeDistancesQuantiles });
        }
Example #9
0
 /// <summary>
 /// If the given node is a file, extracts its radius and adds the given depth to the depth list.
 /// If it is a directory, recursively calls itself for each of its children.
 /// </summary>
 /// <param name="layout"></param>
 /// <param name="addToSizes"></param>
 /// <param name="addToDepths"></param>
 /// <param name="depthToAdd"></param>
 public static void addFilesToList(CircleNode layout, List <double> addToSizes, List <int> addToDepths, int depthToAdd)
 {
     if (layout.GetChildren().Count() > 0)
     {
         foreach (CircleNode n in layout.GetChildren())
         {
             addFilesToList(n, addToSizes, addToDepths, depthToAdd + 1);
         }
     }
     else
     {
         if (layout.SourceTag.Properties["type"].Equals("file"))
         {
             addToSizes.Add(layout.CircleValue.Radius);
             addToDepths.Add(depthToAdd);
         }
     }
 }
Example #10
0
        /// <summary>
        /// Makes a RINGS layout of the tree in the given node.
        /// </summary>
        /// <param name="root">The tree to draw</param>
        /// <param name="size">The size of the layout</param>
        /// <returns></returns>
        public static CircleNode MakeLayout(Tag root, double size)
        {
            CircleNode layout;
            double     origin = size;

            if (root != null)
            {
                Circle tempRootPos;
                //Draw root first
                tempRootPos = new Circle(origin, origin, origin);
                //Console.WriteLine("Root position: "+tempRootPos);
                drawn++;
                layout = new CircleNode(tempRootPos, null,
                                        DrawChildrenOfNode(root, origin, origin, origin));
                return(layout);
            }
            return(null);
        }
Example #11
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();
        }
Example #12
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();
        }
Example #13
0
        /// <summary>
        /// Draws the children of the given node, in the circle
        /// parameters given.
        /// </summary>
        /// <param name="node"></param>
        /// <param name="centerX"></param>
        /// <param name="centerY"></param>
        /// <param name="radius"></param>
        /// <returns></returns>
        static CircleNode[] DrawChildrenOfNode(Tag node, double centerX, double centerY, double radius)
        {
            Console.WriteLine("Layout progress: " + (++drawn * 100) / maxDraw);

            /*if (radius < 1)
             * {
             *      return new CircleNode[] { };
             * }*/
            int childrenDrawn = 0;

            Tag[]        children            = (Tag[])node.GetChildren();
            CircleNode[] childrenCircleNodes = new CircleNode[children.Length];
            //Console.WriteLine("Number of children: " + children.Length);
            int    tempMaxChildrenInLevel;
            double direction, childRadius;

            //Console.WriteLine("Starting sort.");
            sortByNumberOfChildrenLargestFirst(children);
            //Console.WriteLine("Ending sort");
            while (childrenDrawn < children.Length)
            {
                tempMaxChildrenInLevel = findMaxChildrenInLevel(children, childrenDrawn);
                //Console.WriteLine("Max children in level: " + tempMaxChildrenInLevel);
                childRadius = radius - (radius / (Math.Sin(Math.PI / tempMaxChildrenInLevel) + 1));
                //Console.WriteLine("Child Radius: " + childRadius);

                for (int i = 0; i < tempMaxChildrenInLevel; i++)
                {
                    if (tempMaxChildrenInLevel == 1)
                    {
                        Circle c = new Circle(
                            centerX,
                            centerY,
                            radius * 0.9);
                        //Console.WriteLine("Circle: " + c);
                        childrenCircleNodes[i + childrenDrawn] =
                            new CircleNode(c, children[i + childrenDrawn],
                                           DrawChildrenOfNode(children[i + childrenDrawn],
                                                              c.CenterX, c.CenterY, c.Radius));
                    }
                    else
                    {
                        direction = 0 + (((2 * Math.PI) / tempMaxChildrenInLevel) * i);
                        //Console.WriteLine("Direction: " + direction);
                        Circle c = new Circle(
                            centerX + Math.Cos(direction) * (radius - childRadius),
                            centerY + Math.Sin(direction) * (radius - childRadius),
                            childRadius);
                        //Console.WriteLine("Circle: " + c);
                        childrenCircleNodes[i + childrenDrawn] =
                            new CircleNode(c, children[i + childrenDrawn],
                                           DrawChildrenOfNode(children[i + childrenDrawn],
                                                              c.CenterX, c.CenterY, c.Radius));
                    }
                }
                childrenDrawn += tempMaxChildrenInLevel;
                //Console.WriteLine("new children drawn: " + childrenDrawn);
                radius = radius - 2 * childRadius;
                //Console.WriteLine("New radius: " + radius);
            }
            return(childrenCircleNodes);
        }
Example #14
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();
        }