本文整理汇总了C#中Microsoft.Msagl.Drawing.Graph.CreateGeometryGraph方法的典型用法代码示例。如果您正苦于以下问题:C# Graph.CreateGeometryGraph方法的具体用法?C# Graph.CreateGeometryGraph怎么用?C# Graph.CreateGeometryGraph使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Msagl.Drawing.Graph
的用法示例。
在下文中一共展示了Graph.CreateGeometryGraph方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetGraph
private void SetGraph()
{
var graph = new Graph();
graph.AddEdge("a", "b");
graph.AddEdge("e", "b");
graph.AddEdge("d", "b");
graph.AddEdge("b", "c");
graph.AddEdge("a22", "b22");
graph.AddEdge("e22", "b22");
graph.AddEdge("d22", "b22");
graph.AddEdge("b22", "c22");
graph.AddEdge("a0", "b0");
graph.AddEdge("b0", "c0");
graph.AddEdge("a33", "b33");
graph.AddEdge("e33", "b33");
graph.AddEdge("d33", "b33");
graph.AddEdge("b33", "c33");
graph.AddEdge("a11", "b11");
graph.AddEdge("b11", "c11").LabelText = "Test labels!";
graph.CreateGeometryGraph();
foreach (Node node in graph.Nodes)
node.GeometryNode.BoundaryCurve = CreateLabelAndBoundary(node);
foreach (var edge in graph.Edges) {
if (edge.Label != null) {
var geomEdge = edge.GeometryEdge;
double width;
double height;
StringMeasure.MeasureWithFont(edge.LabelText,
new Font(edge.Label.FontName, (float)edge.Label.FontSize), out width, out height);
edge.Label.GeometryLabel=geomEdge.Label = new Label(width, height, geomEdge);
}
}
var geomGraph=graph.GeometryGraph;
var geomGraphComponents = GraphConnectedComponents.CreateComponents(geomGraph.Nodes, geomGraph.Edges);
var settings = new SugiyamaLayoutSettings();
foreach (var subgraph in geomGraphComponents) {
var layout=new LayeredLayout(subgraph, settings);
subgraph.Margins = settings.NodeSeparation/2;
layout.Run();
}
Microsoft.Msagl.Layout.MDS.MdsGraphLayout.PackGraphs(geomGraphComponents, settings);
geomGraph.UpdateBoundingBox();
gViewer1.NeedToCalculateLayout = false;
gViewer1.Graph = graph;
}
示例2: CtreateDrawingGraph
static Graph CtreateDrawingGraph(out FastIncrementalLayoutSettings settings)
{
settings = new FastIncrementalLayoutSettings { RouteEdges = true, NodeSeparation = 30};
var drawingGraph = new Graph();
const string id0 = "0";
const string id1 = "1";
AddEdge(drawingGraph, id0, id1);
AddEdge(drawingGraph, "0", "2");
AddEdge(drawingGraph, "1", "3");
AddEdge(drawingGraph, "2", "4");
AddEdge(drawingGraph, "2", "5");
AddEdge(drawingGraph, "2", "6");
AddEdge(drawingGraph, "5", "7");
AddEdge(drawingGraph, "5", "6");
AddEdge(drawingGraph, "7", "8");
AddEdge(drawingGraph, "8", "6");
drawingGraph.CreateGeometryGraph();
foreach (Microsoft.Msagl.Drawing.Node node in drawingGraph.Nodes) {
double w, h;
var label = node.Label;
var font = new Font(label.FontName, (float)label.FontSize);
StringMeasure.MeasureWithFont(label.Text, font, out w, out h);
node.Label.Width = w;
node.Label.Height = h;
node.Attr.Shape = Shape.DrawFromGeometry;
node.GeometryNode.BoundaryCurve=CurveFactory.CreateRectangleWithRoundedCorners(1.2*w,1.2*h,3,3,new Point());
}
return drawingGraph;
}
示例3: CreateGraphFromParsedStuff
static Graph CreateGraphFromParsedStuff(Dictionary<string, Tuple<int, int, int, int>> labelsToGeom, List<Tuple<string, string>> edges) {
var graph = new Graph();
foreach (var label in labelsToGeom.Keys)
graph.AddNode(label);
foreach (var tuple in edges) {
var e=graph.AddEdge(tuple.Item1, tuple.Item2);
e.Attr.ArrowheadAtTarget = ArrowStyle.None;
}
graph.CreateGeometryGraph();
foreach (var node in graph.Nodes) {
var tuple = labelsToGeom[node.Id];
int centerX = tuple.Item1;
int centerY = tuple.Item2;
int w=tuple.Item3;
int h = tuple.Item4;
node.GeometryNode.BoundaryCurve = new RoundedRect(
new Rectangle(centerX-(double)w/2, centerY-(double)h/2, new Microsoft.Msagl.Core.Geometry.Point(tuple.Item3, tuple.Item4)), 3, 3);
}
var router = new SplineRouter(graph.GeometryGraph, 1, 1, Math.PI / 6, null);
router.Run();
graph.GeometryGraph.UpdateBoundingBox();
//LayoutAlgorithmSettings.ShowGraph(graph.GeometryGraph);
return graph;
}