private void ShowGraphs_Click(object sender, EventArgs e) { Gscc = new KosarajuAlgorithm(G); SCCClrs = new Color[Gscc.SCCCount]; VertexCoords = new Vertex2D[G.VerticesCount]; Random rndm = new Random(); for (int i = 0; i < G.VerticesCount; ++i) { VertexCoords[i].v = i + 1; VertexCoords[i].x = rndm.Next(8, DsplForGraph.Height - 23); VertexCoords[i].y = rndm.Next(8, DsplForGraph.Width - 23); } // очищаем буфер цвета Gl.glClear(Gl.GL_COLOR_BUFFER_BIT); // очищаем текущую матрицу Gl.glLoadIdentity(); for (int i = 0; i < Gscc.SCCCount; ++i) { byte r = (byte)rndm.Next(25, 255); byte g = (byte)rndm.Next(25, 255); byte b = (byte)rndm.Next(25, 255); byte a = 255; Gl.glColor4ub(r, g, b, a); SCCClrs[i] = new Color(r, g, b, a); Gl.glPointSize(13); Gl.glEnable(Gl.GL_POINT_SMOOTH); Gl.glBegin(Gl.GL_POINTS); for (int j = 0; j < Gscc.SCCVrtxCount(i); ++j) Gl.glVertex2i(VertexCoords[Gscc.GetVertex(i, j)].x, VertexCoords[Gscc.GetVertex(i, j)].y); Gl.glEnd(); Gl.glLineWidth(2); for (int j = 0; j < Gscc.SCCEdgCount(i); ++j) PrintVector2D(Gscc.GetEdge(i, j)); } Gl.glColor3i(0, 0, 0); for (int i = 0; i < G.VerticesCount; ++i) for (int j = 0; j < G.VertexDegree(i); ++j) if (!Gscc.StrongConnect(G.GetEdge(i, j).Begin, G.GetEdge(i, j).End)) PrintVector2D(G.GetEdge(i, j)); // расставляем номера у точек for (int i = 0; i < G.VerticesCount; ++i) PrintText2D(VertexCoords[i].x + 2, VertexCoords[i].y + 2, (VertexCoords[i].v).ToString()); // дожидаемся конца визуализации кадра Gl.glFlush(); // посылаем сигнал перерисовки элемента DsplForGraph. DsplForGraph.Invalidate(); }
private void ShowGraphs_Click(object sender, EventArgs e) { Gscc = new KosarajuAlgorithm(G); SCCClrs = new Color[Gscc.SCCCount]; VertexCoords = new Vertex2D[G.VerticesCount]; Random rndm = new Random(); for (int i = 0; i < G.VerticesCount; ++i) { VertexCoords[i].v = i + 1; VertexCoords[i].x = rndm.Next(8, DsplForGraph.Height - 23); VertexCoords[i].y = rndm.Next(8, DsplForGraph.Width - 23); } // очищаем буфер цвета Gl.glClear(Gl.GL_COLOR_BUFFER_BIT); // очищаем текущую матрицу Gl.glLoadIdentity(); for (int i = 0; i < Gscc.SCCCount; ++i) { byte r = (byte)rndm.Next(25, 255); byte g = (byte)rndm.Next(25, 255); byte b = (byte)rndm.Next(25, 255); byte a = 255; Gl.glColor4ub(r, g, b, a); SCCClrs[i] = new Color(r, g, b, a); Gl.glPointSize(13); Gl.glEnable(Gl.GL_POINT_SMOOTH); Gl.glBegin(Gl.GL_POINTS); for (int j = 0; j < Gscc.SCCVrtxCount(i); ++j) { Gl.glVertex2i(VertexCoords[Gscc.GetVertex(i, j)].x, VertexCoords[Gscc.GetVertex(i, j)].y); } Gl.glEnd(); Gl.glLineWidth(2); for (int j = 0; j < Gscc.SCCEdgCount(i); ++j) { PrintVector2D(Gscc.GetEdge(i, j)); } } Gl.glColor3i(0, 0, 0); for (int i = 0; i < G.VerticesCount; ++i) { for (int j = 0; j < G.VertexDegree(i); ++j) { if (!Gscc.StrongConnect(G.GetEdge(i, j).Begin, G.GetEdge(i, j).End)) { PrintVector2D(G.GetEdge(i, j)); } } } // расставляем номера у точек for (int i = 0; i < G.VerticesCount; ++i) { PrintText2D(VertexCoords[i].x + 2, VertexCoords[i].y + 2, (VertexCoords[i].v).ToString()); } // дожидаемся конца визуализации кадра Gl.glFlush(); // посылаем сигнал перерисовки элемента DsplForGraph. DsplForGraph.Invalidate(); }