コード例 #1
0
/*
 *      bool OkToCreateOrOverwriteMsaglFile(string fileName) {
 *          string msaglFileName = CreateMsaglFileNameFromDotName(fileName);
 *          Console.WriteLine(msaglFileName);
 *          if (File.Exists(msaglFileName)) {
 *              string message = String.Format("Do you want to overwrite {0}?", msaglFileName);
 *              MessageBoxResult result = MessageBox.Show(message, "confirm overwrite", MessageBoxButton.YesNo);
 *              if (result == MessageBoxResult.Yes) {
 *                  return true;
 *              }
 *              if (result == MessageBoxResult.No) {
 *                  return false;
 *              }
 *              return false;
 *          }
 *          return true;
 *      }
 */

        void PassGraphToGraphViewer(Graph gwgraph, string fileName)
        {
            CreateTileDirectoryName(fileName);
            FixRoundCorners(gwgraph);
            SetLayoutSettings(gwgraph);
            if (_argsParser.OptionIsUsed(RunRemoveOverlapsOption))
            {
                var compGraph = gwgraph.GeometryGraph;
                switch (new MdsLayoutSettings().OverlapRemovalMethod)
                {
                case OverlapRemovalMethod.Prism:
                    ProximityOverlapRemoval.RemoveOverlaps(compGraph, gwgraph.LayoutAlgorithmSettings.NodeSeparation);
                    break;

                case OverlapRemovalMethod.MinimalSpanningTree:
                    GTreeOverlapRemoval.RemoveOverlaps(compGraph.Nodes.ToArray(),
                                                       gwgraph.LayoutAlgorithmSettings.NodeSeparation);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
            _graphViewer.Graph = gwgraph;
        }
コード例 #2
0
        private ProximityOverlapRemoval RunOverlapRemoval(GeometryGraph graphCopy, GeometryGraph graphOriginal, HashSet <Tuple <int, int> > proximityEdges,
                                                          HashSet <Tuple <int, int, int> > proximityTriangles, List <Tuple <string, double> > statistics, OverlapRemovalSettings settings)
        {
            ProximityOverlapRemoval prism = new ProximityOverlapRemoval(graphCopy);

            prism.Settings = settings;
            Timer timer = new Timer();

            timer.Start();
            prism.RemoveOverlaps();
            timer.Stop();
            var cpuTimeSpan    = TimeSpan.FromSeconds(timer.Duration);
            var statCpuTime    = Tuple.Create("CPUTime", cpuTimeSpan.TotalSeconds);
            var statIterations = Tuple.Create("Iterations", (double)prism.LastRunIterations);

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


            statistics.Add(statCpuTime);
            statistics.Add(statIterations);
            statistics.Add(statEdgeLength);
            statistics.Add(statProcrustes);
            statistics.Add(statArea);
            statistics.Add(statTriangleOrient);
            return(prism);
        }
コード例 #3
0
        void LayoutConnectedGraphWithMds(GeometryGraph compGraph)
        {
            Console.WriteLine("LayoutConnectedGraphWithMds: nodes {0} edges {1}", compGraph.Nodes.Count(), compGraph.Edges.Count());

            double[] x, y;

            LayoutGraphWithMds(compGraph, settings, out x, out y);
            if (settings.RotationAngle != 0)
            {
                Transform.Rotate(x, y, settings.RotationAngle);
            }

            double scaleX = settings.ScaleX;
            double scaleY = settings.ScaleY;
            int    index  = 0;

            foreach (Node node in compGraph.Nodes)
            {
                node.Center = new Point(x[index] * scaleX, y[index] * scaleY);
                index++;
                if ((index % 100) == 0)
                {
                    ProgressStep();
                }
            }
            if (settings.AdjustScale)
            {
                AdjustScale(compGraph.Nodes);
            }

            if (settings.RemoveOverlaps)
            {
                switch (settings.OverlapRemovalMethod)
                {
                case OverlapRemovalMethod.Prism:
                    ProximityOverlapRemoval.RemoveOverlaps(compGraph, settings.NodeSeparation);
                    break;

                case OverlapRemovalMethod.Pmst:
                    OverlapRemoval.RemoveOverlaps(compGraph, settings.NodeSeparation);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
            compGraph.BoundingBox = compGraph.PumpTheBoxToTheGraphWithMargins();
        }
コード例 #4
0
        void GiveGraphToControl(Graph gwgraph)
        {
            if (argsParser.OptionIsUsed(RoundedCornersOption))
            {
                foreach (var n in gwgraph.Nodes)
                {
                    n.Attr.Shape   = Shape.Box;
                    n.Attr.XRadius = n.Attr.YRadius = 3;
                }
            }



            SetLayoutSettings(gwgraph);
            if (argsParser.OptionIsUsed(RunRemoveOverlapsOption))
            {
                var compGraph = gwgraph.GeometryGraph;
                switch (new MdsLayoutSettings().OverlapRemovalMethod)
                {
                case OverlapRemovalMethod.Prism:
                    ProximityOverlapRemoval.RemoveOverlaps(compGraph, gwgraph.LayoutAlgorithmSettings.NodeSeparation);
                    break;

                case OverlapRemovalMethod.Pmst:
                    OverlapRemoval.RemoveOverlaps(compGraph, gwgraph.LayoutAlgorithmSettings.NodeSeparation);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
                if (graphViewer.MsaglFileToSave != null)
                {
                    gwgraph.Write(graphViewer.MsaglFileToSave);
                    Console.WriteLine("saved into {0}", graphViewer.MsaglFileToSave);
                    Environment.Exit(0);
                }
            }


            graphViewer.Graph = gwgraph;
        }