Exemplo n.º 1
0
        private void TestOverlapRemovalOnGraph(string graphName, Graph parentGraph,
                                               HashSet <Tuple <int, int> > proximityEdges, HashSet <Tuple <int, int, int> > proximityTriangles,
                                               Tuple <String, Action <GeometryGraph> > layoutMethod, int layoutPos,
                                               Tuple <string, OverlapRemovalSettings> overlapMethod, int overlapMethodPos)
        {
//            Graph parentGraph = Helper.CopyGraph(parentGraphOriginal);
            var geomGraphOld = Helper.CopyGraph(parentGraph.GeometryGraph);
            var geomGraph    = parentGraph.GeometryGraph;

            graphName = Path.GetFileNameWithoutExtension(graphName);
//            GeometryGraph graph = Helper.CopyGraph(geomGraph);
            List <Tuple <String, double> > statistics = new List <Tuple <string, double> >();

            String layoutMethodName  = layoutMethod.Item1;
            String overlapMethodName = overlapMethod.Item1;
            var    overlapSettings   = overlapMethod.Item2;

            IOverlapRemoval overlapRemover = GetOverlapRemover(overlapSettings, geomGraph);

            overlapRemover.RemoveOverlaps();

            RouteGraphEdges(parentGraph);

            MakeEdgesTransparent(parentGraph);

            List <Tuple <string, double> > kClosestNeighborsError = new List <Tuple <string, double> >();
            var statIterations = RunStats(proximityEdges, proximityTriangles, overlapRemover, geomGraphOld, geomGraph,
                                          kClosestNeighborsError);

            foreach (var t in kClosestNeighborsError)
            {
                statistics.Add(t);
            }
            statistics.Add(statIterations);

            String nameAddon = "-" + layoutPos + "_" + overlapMethodPos + "-" + layoutMethodName + "_" +
                               overlapMethodName;

            parentGraph.GeometryGraph.UpdateBoundingBox();
            DumpProximityCdtToSvg("cdt_" + graphName + nameAddon + ".svg", parentGraph, proximityEdges);


            SvgGraphWriter.WriteAllExceptEdgesInBlack(parentGraph, graphName + nameAddon + ".svg");

            WriteHeader(statistics);
            String line = graphName + "," + geomGraph.Nodes.Count + "," + geomGraph.Edges.Count + "," + layoutMethodName +
                          "," + overlapMethodName;

            double closestNeighErr = 0;

            for (int i = 0; i < statistics.Count; i++)
            {
                Tuple <string, double> stat = statistics[i];
                line += "," + stat.Item2;
                if (stat.Item1.StartsWith("f"))
                {
                    closestNeighErr += stat.Item2;
                }
            }
            ErrorCouple ec;

            if (!_errorDict.TryGetValue(graphName, out ec))
            {
                ec = new ErrorCouple();
                _errorDict[graphName] = ec;
            }
            if (overlapMethodName.Contains("PRISM"))
            {
                ec.prismError = closestNeighErr;
            }
            else
            {
                ec.gtreeError = closestNeighErr;
            }

            WriteLine(line);
        }
Exemplo n.º 2
0
        private static Tuple <string, double> RunStats(HashSet <Tuple <int, int> > proximityEdges, HashSet <Tuple <int, int, int> > proximityTriangles, IOverlapRemoval overlapRemover,
                                                       GeometryGraph geomGraphOld, GeometryGraph geomGraph, List <Tuple <string, double> > sharedFamily)
        {
            var statIterations = Tuple.Create("Iterations", (double)overlapRemover.GetLastRunIterations());

            /*
             * rotationAngleMean = Statistics.Statistics.RotationAngleMean(geomGraphOld, geomGraph, proximityEdges);
             * statProcrustes = Statistics.Statistics.ProcrustesStatistics(geomGraphOld.Nodes.Select(v => v.Center).ToList(),
             *  geomGraph.Nodes.Select(v => v.Center).ToList());
             * statTriangleOrient = Statistics.Statistics.TriangleOrientation(geomGraphOld, geomGraph,
             *  proximityTriangles);
             * statArea = Statistics.Statistics.Area(geomGraph);
             * distortionOfTriangles = Statistics.Statistics.TrianglePropertyError(geomGraphOld, geomGraph, proximityTriangles);*/
            for (int k = 8; k <= 12; k++)
            {
                sharedFamily.Add(Statistics.Statistics.SharedFamily(geomGraphOld, geomGraph, k));
            }
            return(statIterations);
        }