AdjacencyMatrix.xaml.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using System.Windows.Data;
  9. using System.Windows.Documents;
  10. using System.Windows.Input;
  11. using System.Windows.Media;
  12. using System.Windows.Media.Imaging;
  13. using System.Windows.Shapes;
  14. namespace GraphDrawer
  15. {
  16. /// <summary>
  17. /// Interaction logic for AdjacencyMatrix.xaml
  18. /// </summary>
  19. public partial class AdjacencyMatrix : Window
  20. {
  21. public AdjacencyMatrix()
  22. {
  23. InitializeComponent();
  24. }
  25. public AdjacencyMatrix(int[,] matrix, bool state)
  26. {
  27. InitializeComponent();
  28. var length = (int)Math.Sqrt(matrix.Length);
  29. for(int i = 0; i < length; i++)
  30. {
  31. for(int j = 0; j < length; j++)
  32. {
  33. AdjacencyTextBox.Text += matrix[i, j] + ",";
  34. }
  35. AdjacencyTextBox.Text += "\n";
  36. }
  37. if (state)
  38. this.Title = "Матрица инцидентности";
  39. else
  40. this.Title = "Матрица смежности";
  41. }
  42. }
  43. }