Exemplo n.º 1
0
        public void graficar_afd()
        {
            Dictionary <String, String> ids = new Dictionary <string, string>();

            for (int i = 0; i < estados_afd.Count; i++)
            {
                ids.Add(estados_afd.ElementAt(i).puente, "S" + i);
            }
            String file = "digraph dot{\nrankdir=LR;\n node[shape=\"circle\"];\n"
                          + "label = \"AFD de la expresion:\";\n";

            for (int i = 0; i < estados_afd.Count; i++)
            {
                file = file + ids[estados_afd.ElementAt(i).puente] + "[label = \"S" + i + "\"];\n";
                for (int j = 0; j < estados_afd.ElementAt(i).transiciones.Count; j++)
                {
                    String label = estados_afd.ElementAt(i).transiciones.ElementAt(j).valor_tr.getLexema().Replace("\"", "\\\"").Replace("\\\\\"", "\\\"");
                    file = file + ids[estados_afd.ElementAt(i).puente] + "->"
                           + ids[estados_afd.ElementAt(i).transiciones.ElementAt(j).final]
                           + "[label=\"" + label + "\"];\n";
                    if (estados_afd.ElementAt(i).transiciones.ElementAt(j).e_final != null)
                    {
                        if (estados_afd.ElementAt(i).transiciones.ElementAt(j).e_final.aceptacion == true)
                        {
                            file = file + ids[estados_afd.ElementAt(i).transiciones.ElementAt(j).final] + "[shape = \"doublecircle\"];";
                        }
                    }
                }
            }
            file = file + "\n}";
            Generador_Grafica gr = new Generador_Grafica();

            gr.generar_imagen("afd_" + nombre, file);
        }
Exemplo n.º 2
0
        public void imprimir()
        {
            String file         = "digraph G{ \nrankdir=LR;\n node[shape=\"circle\"];";
            Nodo   tmp_cabecera = lista_estados.cabecera;

            while (tmp_cabecera != null)
            {
                Nodo tmp_hijos = tmp_cabecera;
                if (tmp_cabecera.getSiguiente() != null)
                {
                    tmp_hijos = tmp_cabecera.getSiguiente();
                }
                while (tmp_hijos != null)
                {
                    if (tmp_cabecera.getAbajo() != null)
                    {
                        file = file + "S" + tmp_cabecera.getValor().id_estado + "-> S" + tmp_hijos.getValor().id_estado + "[label=\"" + tmp_hijos.getValor().puente.Replace("\"", "\\\"").Replace("\\\\\"", "\\\"") + "\"];\n";
                    }
                    tmp_hijos = tmp_hijos.getSiguiente();
                }
                if (tmp_cabecera.getAbajo() == null)
                {
                    file = file + "S" + tmp_cabecera.getValor().id_estado + "[shape=\"doublecircle\"]\n";
                }
                tmp_cabecera = tmp_cabecera.getAbajo();
            }
            file = file + "\n}";
            Generador_Grafica gr = new Generador_Grafica();

            gr.generar_imagen("afnd_" + nombre, file);
        }
Exemplo n.º 3
0
        public void graficar_tabla()
        {
            String[,] tb = llenar_tabla();
            String file;

            file = "digraph Grafica{\n";

            file = file + "graph [ratio=fill];\n"
                   + "node [label=\"\\N\", fontsize=15, shape=plaintext];\n"
                   + "graph [bb=\"0,0,352,154\"];";

            file = file + "arset [label=<\n"
                   + "        <TABLE ALIGN=\"LEFT\">\n";

            for (int i = 0; i < tb.GetLength(0); i++)
            {
                file = file + "<TR>";
                for (int j = 0; j < tb.GetLength(1); j++)
                {
                    String valor = "--";
                    if (tb[i, j] != null)
                    {
                        valor = tb[i, j].Replace("<", "&#60;").Replace(">", "&#62;");
                    }

                    file = file + "<TD>" + valor + "</TD>\n";
                }
                file = file + "</TR>";
            }

            file = file + "</TABLE>\n>,];\n}";
            Generador_Grafica gr = new Generador_Grafica();

            gr.generar_imagen("tb_" + nombre, file);
        }