static void Main(string[] args)
        {
            try
            {
                int          n      = int.Parse(args[0]);
                List <Arrow> arrows = new List <Arrow>();

                for (int i = 1; i <= n; i++)
                {
                    for (int j = 1; j <= n; j++)
                    {
                        double weight = Convert.ToDouble(args[(i - 1) * n + j]);

                        if (weight >= 0)
                        {
                            arrows.Add(new Arrow(i, j, weight));
                        }
                    }
                }

                List <Arrow> cp = CPM.GetCriticalPath(new WeightedDiGraph(arrows));

                Console.Write(":\nCritical path: " + cp[0].GetBegin());

                double summWeight = 0;
                foreach (Arrow a in cp)
                {
                    summWeight += a.GetWeight();
                    Console.Write(", " + a.GetEnd());
                }
                Console.Write(";\nSumm weight = " + summWeight + ".\n\n");
            }
            catch (IndexOutOfRangeException e)
            {}
        }
        private void SolveButton_Click(object sender, EventArgs e)
        {
            List <Arrow> cp;
            var          thread = new Thread
                                  (
                () =>
            {
                if (!loaded)
                {
                    List <Arrow> arrows = new List <Arrow>();

                    for (int i = 1; i <= vertices; i++)
                    {
                        for (int j = 1; j <= vertices; j++)
                        {
                            double weight = Convert.ToDouble(Controls.Find(i + "," + j, true)[0].Text);

                            if (weight >= 0)
                            {
                                arrows.Add(new Arrow(i, j, weight));
                            }
                        }
                    }

                    G = new WeightedDiGraph(arrows);
                }

                cp = CPM.GetCriticalPath(G);

                solutionBox.Text += "Solution #" + solutionNumber + ":\nCritical path: " + cp[0].GetBegin();

                double summWeight = 0;
                foreach (Arrow a in cp)
                {
                    summWeight       += a.GetWeight();
                    solutionBox.Text += ", " + a.GetEnd();
                }
                solutionBox.Text += ";\nSumm weight = " + summWeight + ".\n\n";
                solutionNumber++;
            }
                                  );

            thread.Start();
            thread.Join();

            /*
             * string args = vertices.ToString();
             *
             * for (int i = 1; i <= vertices; i++)
             *      for (int j = 1; j <= vertices; j++)
             *              args += " " + Controls.Find(i + "," + j, true)[0].Text;
             * solutionBox.Text += "Solution #" + solutionNumber + ExecutableSolve(args);
             * solutionNumber++;
             */
        }
Example #3
0
 /// <summary>
 /// Izvršava se prilikom otvaranja forme.
 /// </summary>
 private void ScoreInput_Load(object sender, EventArgs e)
 {
     this.CenterToScreen();
     lbCPM.Text = CPM.ToString();
     lbWPM.Text = WPM.ToString();
 }
Example #4
0
 public void calculate()
 {
     CPM.compute(this.Activities);
     this.output();
 }