Exemplo n.º 1
0
        private void DFC(int prevVertex, int curVertex)
        {
            VerticesStates[curVertex] = VertexState.active;
            PrevVertices.Push(curVertex);
            if (SaveSteps)
            {
                AddActivationStep(prevVertex, curVertex);
            }

            for (int i = 0; i < VerticesCount; i++)
            {
                CheckConnectedVertex(prevVertex, curVertex, i);
            }


            VerticesStates[curVertex] = VertexState.visited;
            PrevVertices.Pop();
            if (SaveSteps)
            {
                AddLeavingStep(curVertex, prevVertex);
            }
        }
        private void ActivateVertex(int prevVertex, int vertex)
        {
            ActiveVerticesCount++;
            VerticesStates[vertex] = VertexState.active;
            PrevVertices.Push(vertex);

            if (SaveSteps)
            {
                VisualManager.SetVertexColor(vertex, Settings.VERTEX_TO_COLOR);

                if (prevVertex == -1)
                {
                    AddCurrentStep($"Переходим к вершине {vertex}, помечаем её как активную");
                }
                else
                {
                    VisualManager.SetVertexColor(prevVertex, Settings.VERTEX_FROM_COLOR);
                    VisualManager.SetEdgeColor(prevVertex, vertex, Settings.ACTIVE_EDGE_COLOR);
                    AddCurrentStep($"Переходим из вершины {prevVertex} в {vertex}, помечаем {vertex} как активную.");
                    VisualManager.UnsetEdgeColor(prevVertex, vertex);
                }
            }
        }
Exemplo n.º 3
0
        private void ActivateEdge(int from, int to)
        {
            PrevVertices.Push(to);

            if (
                from == -1
                )
            {
                return;
            }

            EdgesActive[from, to] = true;
            if (!Oriented)
            {
                EdgesActive[to, from] = true;
            }

            ActiveEdgesCount++;

            if (SaveSteps)
            {
                AddActivateEdgeStep(from, to);
            }
        }