private void DrawFromMatrixColor(int type) { numberOfVertices = Convert.ToInt32(textBox1.Text); int[,] DrawMatrix = new int[numberOfVertices, numberOfVertices]; for (int i = 0; i < numberOfVertices; i++) { for (int j = 0; j < numberOfVertices; j++) { DrawMatrix[i, j] = Convert.ToInt32(dataGridView1.Rows[i].Cells[j].Value); } } int x = 50; int y = 50; Random randomX = new Random(); Random randomY = new Random(); V.Clear(); E.Clear(); G.clearSheet(); for (int i = 0; i < numberOfVertices; i++) { x = randomX.Next(20, 500); y = randomX.Next(20, 500); V.Add(new Vertex(x, y)); G.drawVertex(x, y, V.Count.ToString()); sheet.Image = G.GetBitmap(); } int c = 0; for (int i = 0; i < numberOfVertices; i++) { for (int j = 0; j < numberOfVertices; j++) { if (DrawMatrix[i, j] != 0) { E.Add(new Edge(i, j)); if (type == 1) { G.drawColorEdge(V[i], V[j], E[E.Count - 1], E.Count - 1, colorsOfVertex[c], type); c++; } else { G.drawColorEdge(V[i], V[j], E[E.Count - 1], E.Count - 1, colorsOfVertex[j], type); } sheet.Image = G.GetBitmap(); } } } }