Exemplo n.º 1
0
        /// <summary>
        /// Creates a forest of unbalanced trees and applies a radial layout.
        /// </summary>
        /// <param name="diagram">The diagram.</param>
        /// <param name="specs">The specs.</param>
        private void RandomRadialForest(RadDiagram diagram, GraphGenerationSpecifications specs)
        {
            this.diagram.Clear();
            Dictionary <Node, RadDiagramShape>      nodeMap;
            Dictionary <Edge, RadDiagramConnection> edgeMap;
            var g        = this.diagram.CreateDiagram(GraphExtensions.CreateRandomGraph(250, 4, true), out nodeMap, out edgeMap, GraphExtensions.CreateShape, this.RandomSizeCheck.IsChecked.HasValue && this.RandomSizeCheck.IsChecked.Value);
            var settings = new TreeLayoutSettings
            {
                TreeLayoutType                  = TreeLayoutType.RadialTree,
                HorizontalSeparation            = this.HorizontalSeparationSlider.Value,
                VerticalSeparation              = this.VerticalSeparationSlider.Value,
                UnderneathHorizontalOffset      = this.UnderneathHorizontalOffsetSlider.Value,
                UnderneathVerticalSeparation    = this.UnderneathVerticalOffsetSlider.Value,
                KeepComponentsInOneRadialLayout = true,
                RadialSeparation                = 45d
            };
            var center = g.FindNode(0);

            settings.Roots.Add(nodeMap[center]);
            var layout = new TreeLayout();

            layout.Layout(this.diagram, settings);
            this.diagram.AutoFit();
            //Colorize(g, nodeMap, center);
        }
Exemplo n.º 2
0
 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);
             diagram.AddShape(shape);
         }
     }
 }