Пример #1
0
        private void NewGraph(int n, int m, int seed, bool isBipartite)
        {
            string str = "Graph: " + n + " " + m + " " + seed + " " + graphCounter;

            graphCounter++;

            GraphParameters gp           = new GraphParameters(n, m, seed, isBipartite);
            UGraph          uGraph       = new UGraph(gp);
            GraphDisplay    graphDisplay = new GraphDisplay(uGraph);

            /*           if (isBipartite)
             *             graphDisplay.BipartiteInit();
             *         else  */
            graphDisplay.CircleInit();

            int[] coloring = Utility.InitIntArray(n, 0);

            GraphEntry ge = new GraphEntry(gp, uGraph, graphDisplay, coloring);

            graphListBox.Items.Add(str);
            graphEntries.Add(ge);



            graphListBox.SetSelected(graphListBox.Items.Count - 1, true);
        }
Пример #2
0
        private void OnRunButtonClick(object sender, EventArgs e)
        {
            GraphDisplay graphDisplay = currentGraphEntry.GraphDisplay;

            int steps = (int)stepsUpDown.Value;
            int reps  = (int)repsUpDown.Value;

            if (graphDisplay != null)
            {
                for (int r = 0; r < reps; r++)
                {
                    for (int i = 0; i < steps; i++)
                    {
                        graphDisplay.SingleStep();
                    }
                    drawingPanel.Refresh();
                    System.Threading.Thread.Sleep(25);

                    statusCountLabel.Text = "Count " + r.ToString();

                    double kineticEnergy = graphDisplay.KineticEnergy / 10000.0;
                    statusKineticEnergyLabel.Text = "Kinetic Energy " + kineticEnergy.ToString("F4");

                    double potentialEnergy = graphDisplay.PotentialEnergy / 10000.0;
                    statusPotentialEnergyLabel.Text = "Potential Energy " + potentialEnergy.ToString("F4");

                    statusStrip1.Refresh();
                }
            }
        }
Пример #3
0
 public GraphEntry(GraphParameters p, UGraph uGraph, GraphDisplay graphDisplay, int[] coloring)
 {
     Param        = p;
     UGraph       = uGraph;
     GraphDisplay = graphDisplay;
     Coloring     = coloring;
     Results      = new List <ColoringResult>();
 }
Пример #4
0
        private void UpdateDisplay()
        {
            int    n      = currentGraphEntry.Param.N;
            int    m      = currentGraphEntry.Param.M;
            UGraph uGraph = currentGraphEntry.UGraph;

            int[]        coloring     = currentGraphEntry.Coloring;
            GraphDisplay graphDisplay = currentGraphEntry.GraphDisplay;

            if (uGraph != null)
            {
                textBox2.Text = currentGraphEntry.UGraph.ToString();
            }
            else
            {
                textBox2.Text = "";
            }

            if (coloring != null)
            {
                int[] colorCount = Utility.ArrayToCount(coloring);
                textBox1.Text = Utility.ArrayToString(colorCount, true);
            }
            else
            {
                textBox1.Text = "";
            }

            statusVertexLabel.Text = "N " + n;
            statusEdgeLabel.Text   = "M " + m;

            if (graphDisplay != null)
            {
                double kineticEnergy = graphDisplay.KineticEnergy / 10000.0;
                statusKineticEnergyLabel.Text = "Kinetic Energy " + kineticEnergy.ToString("F4");

                double potentialEnergy = graphDisplay.PotentialEnergy / 10000.0;
                statusPotentialEnergyLabel.Text = "Potential Energy " + potentialEnergy.ToString("F4");

                statusStrip1.Refresh();
            }

            drawingPanel.Invalidate();
        }
Пример #5
0
        private void OnDrawingPanelPaint(object sender, PaintEventArgs e)
        {
            GraphDisplay graphDisplay = currentGraphEntry.GraphDisplay;

            if (graphDisplay != null)
            {
                Graphics g      = e.Graphics;
                int      h      = drawingPanel.Height;
                int      w      = drawingPanel.Width;
                float    scaleX = drawingPanel.Width / 6.0F;
                float    scaleY = drawingPanel.Height / 6.0F;

                Matrix matrix = new Matrix();
                matrix.Scale(0.65F, -0.65F);
                matrix.Translate(w / 2.0F, h / 2.0F, MatrixOrder.Append);
                g.Transform = matrix;

                graphDisplay.DrawGraph(g, currentGraphEntry.Coloring);
            }
        }