/// <inheritdoc />
        public void Visualize()
        {
            var vertices = _g.Vertices;

            if (!vertices.Any())
            {
                return;
            }

            var rnd = new Random();

            for (var i = 0; i < vertices.Count; ++i)
            {
                var vertex = vertices[i];
                vertex.ModelX      = rnd.NextDouble() * (_g.ActualWidth - 2 * _g.DefaultVertexRadius) + _g.DefaultVertexRadius;
                vertex.ModelY      = rnd.NextDouble() * (_g.ActualHeight - 2 * _g.DefaultVertexRadius) + _g.DefaultVertexRadius;
                vertex.ScaleFactor = 1;

                var j = 0;
                for (; j < i; j++)
                {
                    if (GraphVisualizer.AreIntersecting(vertex, (Vertex)vertices[j]))
                    {
                        break;
                    }
                }
                if (j < i)
                {
                    --i;
                }
            }
        }
Example #2
0
 public void InitializeComponent()
 {
     if (_contentLoaded)
     {
         return;
     }
     _contentLoaded = true;
     System.Windows.Application.LoadComponent(this, new System.Uri("/GraphLabs.Tasks.Template;component/Planarity.xaml", System.UriKind.Relative));
     this.BusyIndicator  = ((System.Windows.Controls.BusyIndicator)(this.FindName("BusyIndicator")));
     this.LayoutRoot     = ((System.Windows.Controls.Grid)(this.FindName("LayoutRoot")));
     this.LeftMainBorder = ((System.Windows.Controls.Border)(this.FindName("LeftMainBorder")));
     this.Matrix         = ((GraphLabs.CommonUI.Controls.Matrix)(this.FindName("Matrix")));
     this.ToolBar        = ((GraphLabs.CommonUI.Controls.ToolBar)(this.FindName("ToolBar")));
     this.Visualizer     = ((GraphLabs.Graphs.UIComponents.Visualization.GraphVisualizer)(this.FindName("Visualizer")));
 }
 /// <summary>
 /// constr
 /// </summary>
 public CirclePositionsVisualizer(GraphVisualizer g)
 {
     g_ = g;
 }
 /// <summary>
 /// constructor
 /// </summary>
 /// <param name="g"></param>
 public RandomPositionVisualizer(GraphVisualizer g)
 {
     _g = g;
 }