Beispiel #1
0
        private void SetEnter_TextChanged(object sender, EventArgs e)
        {
            _graph = new SimpleUndirectedGraph <string, string>();
            Set    = new Dictionary <string, int>();
            string SetString = "";

            foreach (var symbol in SetEnter.Text)
            {
                if (symbol != ',')
                {
                    SetString += symbol;
                }
                else
                {
                    if (SetString != "")
                    {
                        if (!Set.Keys.Contains(SetString))
                        {
                            Set.Add(SetString, 0);
                        }
                        SetString = "";
                    }
                }
            }
            if (SetString != "")
            {
                if (!Set.Keys.Contains(SetString))
                {
                    Set.Add(SetString, 0);
                }
                SetString = "";
            }
            SetOutPut.Text = "Вершины графа:";
            foreach (var element in Set.Keys)
            {
                if (Set.Keys.ToList().IndexOf(element) == 0)
                {
                    SetOutPut.Text += element;
                }
                else
                {
                    SetOutPut.Text += ", " + element;
                }
                _graph.AddVertex(element);
            }
        }
 public void SetUp()
 {
     _graph = new SimpleUndirectedGraph <string, string>();
     _graph.AddVertex(new[] { "A", "B", "C", "D" });
 }