void ProcessMsagl(string fileName)
        {
            var graph = Graph.Read(fileName);

            if (graph != null)
            {
                if (argsParser.OptionIsUsed(PrintMaxNodeDegreeOption))
                {
                    Console.WriteLine("max node degree {0}",
                                      graph.Nodes.Max(n => n.OutEdges.Count() + n.InEdges.Count() + n.SelfEdges.Count()));
                    System.Environment.Exit(0);
                }


                if (argsParser.OptionIsUsed(RoundedCornersOption))
                {
                    foreach (var n in graph.Nodes)
                    {
                        n.Attr.XRadius = n.Attr.YRadius = 3;
                    }
                }

                if (argsParser.OptionIsUsed(RunRemoveOverlapsOption))
                {
                    OverlapRemoval.RemoveOverlaps(graph.GeometryGraph,
                                                  graph.LayoutAlgorithmSettings.NodeSeparation);
                }
            }

            GiveGraphToControlFromMsagl(graph);
        }
         void SetNodePositionsAndMovedBoundaries() {
            
            int pivotNumber = Math.Min(graph.Nodes.Count,settings.PivotNumber);
            double scaleX = settings.ScaleX;
            double scaleY = settings.ScaleY;
          
            int[] pivotArray = new int[pivotNumber];
            PivotDistances pivotDistances = new PivotDistances(graph, false, pivotArray);
            pivotDistances.Run();
            double[][] c = pivotDistances.Result;
            double[] x, y;
            MultidimensionalScaling.LandmarkClassicalScaling(c, out x, out y, pivotArray);

            Standardize(x);
            double[] p = Centrality.PageRank(graph, .85, false);
            // double[] q = Centrality.PageRank(graph, .85, true);
            Standardize(p);
            // Standardize(q);

            int index = 0;
            foreach (Node node in graph.Nodes) {
                node.Center = new Point((int) (x[index]*scaleX), (int) (Math.Sqrt(p[index])*scaleY));
                index++;
            }

            OverlapRemoval.RemoveOverlaps(graph.Nodes.ToArray(), settings.NodeSeparation);
        }
/*
 *      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:
                    OverlapRemoval.RemoveOverlaps(compGraph.Nodes.ToArray(),
                                                  gwgraph.LayoutAlgorithmSettings.NodeSeparation);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
            _graphViewer.Graph = gwgraph;
        }
        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();
        }
        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;
        }