Ejemplo n.º 1
0
 private bool IsOnThePath(MyPipe pipe, List <List <string> > binaryPaths)
 {
     foreach (var binaryPath in binaryPaths)
     {
         if (pipe.StartingPoint == binaryPath[0] && pipe.EndPoint == binaryPath[1])
         {
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 2
0
 private bool IsMinCutPipe(MyPipe myPipe, List <MyPipe> minCutPipes)
 {
     foreach (var minCutPipe in minCutPipes)
     {
         if (myPipe.StartingPoint == minCutPipe.StartingPoint &&
             myPipe.EndPoint == minCutPipe.EndPoint)
         {
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 3
0
        private void btnPipeCapacity_Click(object sender, EventArgs e)
        {
            MyPipe pipe  = new MyPipe();
            MyPipe pipe2 = new MyPipe();
            int    capacity1;
            int    capacity2;
            string name1;
            string name2;
            MyNode node1 = new MyNode();
            MyNode node2 = new MyNode();
            MyNode node  = new MyNode();

            //Textbox boş ise
            if (String.IsNullOrEmpty(tbxPipe1Capacity.Text))
            {
                capacity1 = 0;
            }
            else
            {
                capacity1 = Int32.Parse(tbxPipe1Capacity.Text);
            }
            //Textbox boş ise
            if (String.IsNullOrEmpty(tbxPipe2Capacity.Text))
            {
                capacity2 = 0;
            }
            else
            {
                capacity2 = Int32.Parse(tbxPipe2Capacity.Text);
            }

            tbxPipe1Capacity.Text = string.Empty;
            tbxPipe2Capacity.Text = string.Empty;

            name1 = lblPipeName1.Text;
            name2 = lblPipeName2.Text;

            //baslangic
            if (capacity1 != 0)
            {
                pipe.StartingPoint = name1;
                pipe.EndPoint      = name2;
                pipe.StartingValue = capacity1;
                node = listOfNodes.Where(x => x.Name == name1).FirstOrDefault();
                node.Pipes.Add(pipe);

                myGraph.Pipes.Add(pipe);
                myGraph.Nodes = listOfNodes;
            }
            else if (capacity2 != 0)
            {
                pipe.StartingPoint = name2;
                pipe.EndPoint      = name1;
                pipe.StartingValue = capacity2;
                node = listOfNodes.Where(x => x.Name == name2).FirstOrDefault();
                node.Pipes.Add(pipe);

                myGraph.Pipes.Add(pipe);
                myGraph.Nodes = listOfNodes;
            }

            /*
             * pipe.StartingPoint = name1;
             * pipe.EndPoint = name2;
             *
             * pipe2.StartingPoint = name2;
             * pipe2.EndPoint = name1;
             *
             *
             * pipe.StartingValue = capacity1;
             * pipe.EndingValue = capacity2;
             *
             * pipe2.StartingValue = capacity2;
             * pipe2.EndingValue = capacity1;
             *
             * node1 = listOfNodes.Where(x => x.Name == name1).FirstOrDefault();
             * node2 = listOfNodes.Where(x => x.Name == name2).FirstOrDefault();
             *
             * myGraph.Pipes.Add(pipe);
             * myGraph.Nodes = listOfNodes;
             *
             * node1.Pipes.Add(pipe);
             *
             * node2.Pipes.Add(pipe2);
             */
            pnlPipeCapacity.Hide();
        }