void ProcessMsagl(string fileName) { Console.WriteLine("reading {0}", 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())); Environment.Exit(0); } if (_argsParser.OptionIsUsed(RoundedCornersOption)) { foreach (var n in graph.Nodes) { n.Attr.XRadius = n.Attr.YRadius = 3; } } if (_argsParser.OptionIsUsed(RunRemoveOverlapsOption)) { GTreeOverlapRemoval.RemoveOverlaps(graph.GeometryGraph.Nodes.ToArray(), graph.LayoutAlgorithmSettings.NodeSeparation); } } Console.WriteLine("passing graph to the control"); PassGraphToControl(graph, fileName); }
void ProcessMsagl(string fileName) { var graph = Graph.Read(fileName); if (graph != null) { if (argsParser.OptionIsUsed(PrintMaxNodeDegreeOption)) { System.Diagnostics.Debug.WriteLine("max node degree {0}", graph.Nodes.Max(n => n.OutEdges.Count() + n.InEdges.Count() + n.SelfEdges.Count())); Environment.Exit(0); } if (argsParser.OptionIsUsed(RoundedCornersOption)) { foreach (var n in graph.Nodes) { n.Attr.XRadius = n.Attr.YRadius = 3; } } if (argsParser.OptionIsUsed(RunRemoveOverlapsOption)) { GTreeOverlapRemoval.RemoveOverlaps(graph.GeometryGraph.Nodes.ToArray(), graph.LayoutAlgorithmSettings.NodeSeparation); } } GiveGraphToControlFromMsagl(graph); }
/* * 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; }
void SetNodePositionsAndMovedBoundaries(GeometryGraph graph) { 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++; } GTreeOverlapRemoval.RemoveOverlaps(graph.Nodes.ToArray(), settings.NodeSeparation); }
void PassGraphToControl(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; GTreeOverlapRemoval.RemoveOverlaps(compGraph.Nodes.ToArray(), gwgraph.LayoutAlgorithmSettings.NodeSeparation); if (graphViewer.MsaglFileToSave != null) { gwgraph.Write(graphViewer.MsaglFileToSave); System.Diagnostics.Debug.WriteLine("saved into {0}", graphViewer.MsaglFileToSave); Environment.Exit(0); } } graphViewer.Graph = gwgraph; }
void LayoutConnectedGraphWithMds(GeometryGraph compGraph) { 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) { GTreeOverlapRemoval.RemoveOverlaps(compGraph.Nodes.ToArray(), settings.NodeSeparation); } compGraph.BoundingBox = compGraph.PumpTheBoxToTheGraphWithMargins(); }
/* * bool OkToCreateOrOverwriteMsaglFile(string fileName) { * string msaglFileName = CreateMsaglFileNameFromDotName(fileName); * System.Diagnostics.Debug.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; GTreeOverlapRemoval.RemoveOverlaps(compGraph.Nodes.ToArray(), gwgraph.LayoutAlgorithmSettings.NodeSeparation); } _graphViewer.Graph = gwgraph; }
void LayoutConnectedGraphWithMds(GeometryGraph compGraph) { Debug.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.MinimalSpanningTree: GTreeOverlapRemoval.RemoveOverlaps(compGraph.Nodes.ToArray(), settings.NodeSeparation); break; default: throw new ArgumentOutOfRangeException(); } } compGraph.BoundingBox = compGraph.PumpTheBoxToTheGraphWithMargins(); }
private void Calculate(GeometryGraph graph) { if (graph.Nodes.Count == 0) { return; } SetNodePositionsAndMovedBoundaries(graph); double nodeSeparation = settings.NodeSeparation; if (nodeSeparation <= 0) { nodeSeparation = 10; } GTreeOverlapRemoval.RemoveOverlaps(graph.Nodes.ToArray(), nodeSeparation); SetGraphBoundingBox(graph); }
void PassGraphToControl(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.MinimalSpanningTree: GTreeOverlapRemoval.RemoveOverlaps(compGraph.Nodes.ToArray(), 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; }