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;
//            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();

            RefreshAndCleanGraph(parentGraph);


            var statIterations = Tuple.Create("Iterations", (double)overlapRemover.GetLastRunIterations());

            var statEdgeLength = Statistics.Statistics.EdgeLengthDeviation(geomGraphOld, geomGraph, proximityEdges);
            var statProcrustes =
                Statistics.Statistics.ProcrustesStatistics(geomGraphOld.Nodes.Select(v => v.Center).ToList(),
                                                           geomGraph.Nodes.Select(v => v.Center).ToList());
            var statTriangleOrient = Statistics.Statistics.TriangleOrientation(geomGraphOld, geomGraph, proximityTriangles);
            var statArea           = Statistics.Statistics.Area(geomGraph);

//            statistics.Add(Tuple.Create());
            statistics.Add(statIterations);
            statistics.Add(statEdgeLength);
            statistics.Add(statProcrustes);
            statistics.Add(statArea);
            statistics.Add(statTriangleOrient);

            String nameAddon = "-" + layoutPos.ToString() + "_" + overlapMethodPos + "-" + layoutMethodName + "_" +
                               overlapMethodName;

//            RefreshAndCleanGraph(parentGraph);
//           Parallel.Invoke(
//            ()=>parentGraph.Write(graphName + nameAddon+".msagl"),
//            () =>
            SvgGraphWriter.Write(parentGraph, graphName + nameAddon + ".svg");
//
//            );

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

            for (int i = 0; i < statistics.Count; i++)
            {
                Tuple <string, double> stat = statistics[i];
                line += "," + stat.Item2;
            }
            WriteLine(line);
        }
Exemplo n.º 2
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);
        }