Beispiel #1
0
        private void btnFindMaxFlow_Click(object sender, EventArgs e)
        {
            ParseData();
            FindAugmentingPathMethod Method = (FindAugmentingPathMethod)Enum.Parse(typeof(FindAugmentingPathMethod), cbMethod.SelectedIndex.ToString());

            var Sourse = Nodes[0];
            var Sink   = Nodes[Nodes.Count - 1];

            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();

            ford = new FordFulkerson(Nodes, Edges, Sourse, Sink);
            float maxFlow = ford.Run(Method);

            stopWatch.Stop();

            // Get the elapsed time as a TimeSpan value.
            TimeSpan ts = stopWatch.Elapsed;

            // Format and display the TimeSpan value.
            string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:000}",
                                               ts.Hours, ts.Minutes, ts.Seconds,
                                               ts.Milliseconds);

            tbMaxFlow.Text = maxFlow.ToString() + " # " + ts.Ticks;

            if (Trials > 0)
            {
                Times[cbMethod.SelectedIndex].Add(ts.Ticks);
            }
            tbAvgTime.Text = Times[cbMethod.SelectedIndex].Count > 0 ? Times[cbMethod.SelectedIndex].Average().ToString() : "0";
            ShowAugmentingPaths();
            Trials++;
        }
Beispiel #2
0
        public void UseAlgorithm(List <TextBox> textBoxes, int integer, int startPoint, int endPoint)
        {
            this.textBoxes = textBoxes;
            this.integer   = integer;

            CreateMatrix();

            FordFulkerson fordFulkerson = new FordFulkerson();

            maxFlow = fordFulkerson.Run(matrix, startPoint, endPoint, integer);

            label1.Text = "Maximum flow of the graph is " + maxFlow.ToString();
        }
Beispiel #3
0
        private void btnGlobal_Click(object sender, EventArgs e)
        {
            ParseData();
            FindAugmentingPathMethod Method = (FindAugmentingPathMethod)Enum.Parse(typeof(FindAugmentingPathMethod), cbMethod.SelectedIndex.ToString());

            var                    Sourse    = Nodes[0];
            List <string>          resutls   = new List <string>();
            Dictionary <int, Node> NodesCopy = new Dictionary <int, Node>(Nodes);

            foreach (Node Sink in NodesCopy.Values)
            {
                Sourse = Nodes[0];
                var t = Nodes[Sink.Id];
                ford = new FordFulkerson(Nodes, Edges, Sourse, t);
                float maxFlow = ford.Run(Method);

                resutls.Add(Sourse.Name + "--" + maxFlow + "-->" + Sink.Name);
                ParseData();
            }
        }
Beispiel #4
0
        public void Exemplu(int i)
        {
            Exemple exemplu = new Exemple();

            if (i == 1)
            {
                exemplu.Exemplu1();
            }
            else if (i == 2)
            {
                exemplu.Exemplu2();
            }
            else if (i == 3)
            {
                exemplu.Exemplu3();
            }

            FordFulkerson fordFulkerson = new FordFulkerson();

            maxFlow     = fordFulkerson.Run(exemplu.graph, exemplu.startPoint, exemplu.endPoint, exemplu.integer);
            label1.Text = "Maximum flow of the graph is " + maxFlow.ToString();
        }