/// <summary> /// Creates a balanced radial forest. /// </summary> /// <param name="diagram">The diagram.</param> /// <param name="specs">The specs.</param> public static void BalancedRadialForest(this RadDiagram diagram, GraphGenerationSpecifications specs) { diagram.Clear(); Dictionary<Node, RadDiagramShape> nodeMap; Dictionary<Edge, RadDiagramConnection> edgeMap; var g = diagram.CreateDiagram(CreateBalancedForest(), out nodeMap, out edgeMap, CreateShape, specs.RandomShapeSize); var settings = new TreeLayoutSettings { TreeLayoutType = specs.TreeType, HorizontalSeparation = specs.HorizontalSeparation, VerticalSeparation = specs.VerticalSeparation, UnderneathHorizontalOffset = specs.UnderneathHorizontalOffset, UnderneathVerticalSeparation = specs.UnderneathVerticalSeparation, KeepComponentsInOneRadialLayout = specs.KeepComponentsInOneRadialLayout }; var center = g.FindNode(1); settings.Roots.Add(nodeMap[center]); var layout = new TreeLayout(); layout.Layout(diagram, settings); diagram.AutoFit(); }
public static void CreateGraph(this RadDiagram diagram, GraphGenerationSpecifications specs, CreateShapeDelegate createShape) { diagram.Clear(); if (specs.Connections) { var g = specs.Connected ? GraphExtensions.CreateRandomConnectedGraph(specs.NodeCount, 4, specs.TreeGraph) : GraphExtensions.CreateRandomGraph(specs.NodeCount, 4, specs.TreeGraph); diagram.CreateDiagram(g, GraphExtensions.CreateShape, specs.RandomShapeSize); } else { for (var i = 0; i < specs.NodeCount; i++) { var shape = createShape(new Node(i, false), specs.RandomShapeSize, null); diagram.AddShape(shape); } } }