Ejemplo n.º 1
0
        private void PairsSet_TextChanged(object sender, EventArgs e)
        {
            Pairs = new List <Pairs>();
            _graph.DeleteEdges();
            string A          = "";
            string B          = "";
            string SetString  = "";
            bool   isPairMade = false;

            foreach (var symbol in PairsSet.Text)
            {
                if (Char.IsDigit(symbol) || Char.IsLetter(symbol))
                {
                    SetString += symbol;
                }
                else
                {
                    if (SetString != "")
                    {
                        if (Set != null)
                        {
                            if (isPairMade == false)
                            {
                                isPairMade = true;
                                A          = SetString;
                                SetString  = "";
                            }
                            else
                            {
                                isPairMade = false;
                                B          = SetString;
                                if (!Classes.Pairs.Contains(Pairs, new Pairs(A, B)) && ((Set.Keys.Contains(A) && (Set.Keys.Contains(B)))))
                                {
                                    Pairs.Add(new Pairs(A, B));
                                    if (!Classes.Pairs.Contains(Pairs, new Pairs(B, A)) && ((Set.Keys.Contains(B) && (Set.Keys.Contains(A)))))
                                    {
                                        Pairs.Add(new Pairs(B, A));
                                    }
                                }
                                SetString = "";
                            }
                        }
                        SetString = "";
                    }
                }
            }
            if ((SetString != "") && (isPairMade == true))
            {
                isPairMade = false;
                B          = SetString;
                if (!Classes.Pairs.Contains(Pairs, new Pairs(A, B)) && ((Set.Keys.Contains(A) && (Set.Keys.Contains(B)))))
                {
                    Pairs.Add(new Pairs(A, B));
                    if (!Classes.Pairs.Contains(Pairs, new Pairs(B, A)) && ((Set.Keys.Contains(B) && (Set.Keys.Contains(A)))))
                    {
                        Pairs.Add(new Pairs(B, A));
                    }
                }
                SetString = "";
            }
            PairsOutPut.Text = "Ребра графа:";
            foreach (var element in Pairs)
            {
                PairsOutPut.Text += "(" + element.a + " , " + element.b + ") ";
                _graph.AddEdge(element.a, element.b, "");
            }
        }
 public void AddEdgeThrowsArumentNullException()
 {
     Assert.That(() => _graph.AddEdge(null, "B", "L1"), Throws.ArgumentNullException);
     Assert.That(() => _graph.AddEdge("A", null, "L1"), Throws.ArgumentNullException);
     Assert.That(() => _graph.AddEdge("A", "B", null), Throws.ArgumentNullException);
 }