// TNode tree; private void TextBox_TextChanged(object sender, TextChangedEventArgs e) { if (String.IsNullOrEmpty((sender as TextBox).Text) || (sender as TextBox).Text[(sender as TextBox).Text.Length - 1] != ';') { return; } string seq = (sender as TextBox).Text.Remove((sender as TextBox).Text.Length - 1); string[] arr = seq.Split(',').ToArray(); if (arr.Length < 2) { return; } List <int> sequence = new List <int>(); foreach (string item in arr) { if (!String.IsNullOrEmpty(item)) { sequence.Add(int.Parse(item)); } } Prufer pruf = new Prufer(); TNode result = pruf.decode5(sequence); graph.Items.Clear(); graph.Items.Add(result); }
public MainWindow() { InitializeComponent(); // test(); // test2(); // test3(); //test4(); //test5(); //test6(); //test7(); // a1(); // a2(); // a3(); //a4(); //public void test() //{ TNode root = new TNode(1); root.AddChild(2); root.Children[0].AddChild(3); root.Children[0].AddChild(5); root.Children[0].Children[1].AddChild(4); root.Children[0].Children[1].AddChild(6); //} List <int> sequence = new List <int>() { 5, 3, 5, 3, 5 }; Prufer pruf = new Prufer(); // TNode result = pruf.decode(sequence); // graph.Items.Add(result); }
private void button2_Click(object sender, EventArgs e) { Prufer prufer = new Prufer(); if (TNode.CountVertices(root) < 3) { lbPrufer.Text = "Drzewo musi zawierać więcej niz 2 węzły"; lbPrufer.ForeColor = Color.Red; return; } int[] result = prufer.encode(root); string txt = String.Join(",", result); lbPrufer.ForeColor = Color.Black; lbPrufer.Text = txt; }
private void button1_Click(object sender, EventArgs e) { if (String.IsNullOrEmpty(tbCiag.Text)) { return; } string[] arr = tbCiag.Text.Split(',').ToArray(); List <int> sequence = new List <int>(); foreach (string item in arr) { if (!String.IsNullOrEmpty(item)) { sequence.Add(int.Parse(item)); } } Prufer pruf = new Prufer(); root = pruf.decode(sequence); ArrangeTree(); }