Beispiel #1
0
        public string GenerarGraphivizAFDTabla()
        {
            string text = "node[ shape = none, fontname = \"Arial\" ];\n";

            text += "set1[ label=<" + "<TABLE BORDER=\"0\" CELLBORDER=\"1\" CELLSPACING=\"0\" CELLPADDING=\"4\">\n";
            text += " <TR>\n<TD> Estado </TD>";
            List <Mueve> sinRepeticion = new List <Mueve>();

            foreach (var simbolo in listaTerminales)
            {
                text += "<TD>" + simbolo + "</TD>";
            }
            text += "</TR>\n";
            bool entrada;

            for (int i = 0; i < mueves.Count - 1; i++)
            {
                string estadoAct = mueves.ElementAt(i).GetInicialString();
                //Estado
                if (!text.Contains("<TR>\n<TD>" + estadoAct + "</TD>"))
                {
                    sinRepeticion.Add(mueves.ElementAt(i));
                    text   += "<TR>\n<TD>" + estadoAct + "</TD>";
                    entrada = false;
                    for (int j = 0; j < mueves.Count; j++)
                    {
                        if (estadoAct.Equals(mueves.ElementAt(j).GetInicialString()))
                        {
                            if (mueves.ElementAt(j).GetLlegadaString().Equals("-1"))
                            {
                                text += "<TD> - </TD>";
                            }
                            else
                            {
                                text += "<TD>" + mueves.ElementAt(j).GetLlegadaString() + "</TD>";
                            }

                            entrada = true;
                        }
                        else if (entrada == true)//ya se encontraron todos
                        {
                            i = j - 1;
                            break;
                        }
                    }
                    text += "</TR>";
                }
                else
                {
                    break;
                }
            }
            text  += "</TABLE>>];";
            mueves = sinRepeticion;
            Graficador graficador = new Graficador();

            return(graficador.GraphvizAFDTabla(text));
        }
Beispiel #2
0
        public string GenerarGraphvizAFD()
        {
            string       text        = "A -> 0;";
            List <Mueve> listaMueves = new List <Mueve>();

            for (int i = 0; i < mueves.Count; i++)
            {
                Mueve mueve = mueves.ElementAt(i);


                if (!mueve.GetLlegadaString().Equals("-1") && !text.Contains(mueve.GetInicialString() + " -> " + mueve.GetLlegadaString() + "[label=\"" + mueve.GetSimbolo() + "\"]"))
                {
                    text += mueve.GetInicialString() + " -> " + mueve.GetLlegadaString() + "[label=\"" + mueve.GetSimbolo() + "\"]";
                    listaMueves.Add(mueve);
                }
            }
            mueveSinVacio = listaMueves;
            string formas = "A[shape = point]";

            foreach (var item in mueves)
            {
                if (item.GetEstadoInicial().GetNombreEstadoAFD() != -1)
                {
                    if (!formas.Contains(item.GetInicialString() + "[shape = doublecircle];"))
                    {
                        if (item.GetEstadoInicial().GetTipo() == EstadoAFD.Tipo.FINAL)
                        {
                            formas += item.GetInicialString() + "[shape = doublecircle];";
                        }
                    }
                }
            }
            text += formas;

            Graficador graficador = new Graficador();

            return(graficador.GraphvizAFD(text));
        }
        public string GenerarGraphviz()
        {
            Graficador graficador = new Graficador();

            return(graficador.GraphvizAFN(stackAFN));
        }