int[,] CreateMatrix() { int[,] array = new int[this.Controls.Count - 1, this.Controls.Count - 1]; for (int i = 0; i < array.GetLength(0); i++) { for (int j = 0; j < array.GetLength(0); j++) { if (_edges.Contains(new Edge(i + 1, j + 1), this.IsUndirectedGraph)) { array[i, j] = GetDistance(this.Controls[i + 1].Location, this.Controls[j + 1].Location); } else if (i != j) { array[i, j] = -1; } } } return(array); }