Exemplo n.º 1
0
        private void GenStrongConnectedComponentGraph()
        {
            StrongConnectedComponentGraph = new KosarajuAlgorithm(Graph);
            GenStrongConnectedComponentColors();

            strongConnectedComponentInfo = new StrongConnectedComponentInfo(StrongConnectedComponentGraph, StrongConnectedComponentColors);

            GenVertexCoord();
        }
 public StrongConnectedComponentInfo(KosarajuAlgorithm strongConnectedComponent, RGBColor[] vertexColors)
 {
     StrongConnectedComponent = strongConnectedComponent;
     VertexColors = vertexColors;
 }
Exemplo n.º 3
0
 public SCCInfo(KosarajuAlgorithm scc, HelpKsyuMainWindow.Color[] v_clrs)
 {
     InitializeComponent();
     SCC     = scc;
     VrtClrs = v_clrs;
 }
 public StrongConnectedComponentInfo(KosarajuAlgorithm strongConnectedComponent, RGBColor[] vertexColors)
 {
     StrongConnectedComponent = strongConnectedComponent;
     VertexColors             = vertexColors;
 }
Exemplo n.º 5
0
        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();
        }
Exemplo n.º 6
0
        private void GenStrongConnectedComponentGraph()
        {
            StrongConnectedComponentGraph = new KosarajuAlgorithm(Graph);
            GenStrongConnectedComponentColors();

            strongConnectedComponentInfo = new StrongConnectedComponentInfo(StrongConnectedComponentGraph, StrongConnectedComponentColors);

            GenVertexCoord();
        }
Exemplo n.º 7
0
 public SCCInfo(KosarajuAlgorithm scc, HelpKsyuMainWindow.Color[] v_clrs)
 {
     InitializeComponent();
     SCC = scc;
     VrtClrs = v_clrs;
 }
Exemplo n.º 8
0
        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();
        }