Exemple #1
0
        /**
         * Print the DA in DOT format to the output stream.
         * This functions expects that the DA is compact.
         * @param da_type a string specifying the type of automaton ("DRA", "DSA").
         * @param out the output stream
         */
        public Graph AutomatonToDot()
        {
            Graph g = new Graph("graph");

            g.Directed = true;


            APSet ap_set = getAPSet();
            Dictionary <int, string> stateToNumber = new Dictionary <int, string>();

            for (int i_state = 0; i_state < this.size(); i_state++)
            {
                //out << "\"" << i_state << "\" [";

                Node d = formatStateForDOT(i_state, g);
                stateToNumber.Add(i_state, d.Id);
            }

            //out << "]\n"; // close parameters for state

            for (int i_state = 0; i_state < this.size(); i_state++)
            {
                // transitions

                DA_State cur_state = this.get(i_state);
                if (cur_state.hasOnlySelfLoop())
                {
                    // get first to-state, as all the to-states are the same
                    DA_State to = cur_state.edges().get(new APElement(ap_set.all_elements_begin()));

                    //out << "\"" << i_state << "\" -> \"" << to->getName();
                    //out << "\" [label=\" true\", color=blue]\n";

                    Edge edge = g.AddEdge(stateToNumber[i_state], "\u03A3", stateToNumber[to.getName()]);
                    //edge.Attr.Color = Color.Blue;
                }
                else
                {
                    //for (APSet::element_iterator el_it=ap_set.all_elements_begin();el_it!=ap_set.all_elements_end();++el_it)
                    for (int el_it = ap_set.all_elements_begin(); el_it != ap_set.all_elements_end(); ++el_it)
                    {
                        APElement label          = new APElement(el_it);
                        DA_State  to_state       = cur_state.edges().get(label);
                        int       to_state_index = to_state.getName();
                        //out << "\"" << i_state << "\" -> \"" << to_state_index;
                        //out << "\" [label=\" " << label.toString(getAPSet(), false) << "\"]\n";


                        Edge edge = g.AddEdge(stateToNumber[i_state], label.toString(getAPSet(), false), stateToNumber[to_state_index]);
                        //edge.Attr.Color = Color.Blue;
                    }
                }
            }

            return(g);
        }
Exemple #2
0
        /**
         * Print the DA in DOT format to the output stream.
         * This functions expects that the DA is compact.
         * @param da_type a string specifying the type of automaton ("DRA", "DSA").
         * @param out the output stream
         */
        public Graph AutomatonToDot()
        {
            Graph g = new Graph("graph");
            g.Directed = true;

            APSet ap_set = getAPSet();
            Dictionary<int, string> stateToNumber = new Dictionary<int, string>();

            for (int i_state = 0; i_state < this.size(); i_state++)
            {
                //out << "\"" << i_state << "\" [";

                Node d = formatStateForDOT(i_state, g);
                stateToNumber.Add(i_state, d.Id);
            }

            //out << "]\n"; // close parameters for state

            for (int i_state = 0; i_state < this.size(); i_state++)
            {
                // transitions

                DA_State cur_state = this.get(i_state);
                if (cur_state.hasOnlySelfLoop())
                {
                    // get first to-state, as all the to-states are the same
                    DA_State to = cur_state.edges().get(new APElement(ap_set.all_elements_begin()));

                    //out << "\"" << i_state << "\" -> \"" << to->getName();
                    //out << "\" [label=\" true\", color=blue]\n";

                    Edge edge = g.AddEdge(stateToNumber[i_state], "\u03A3", stateToNumber[to.getName()]);
                    //edge.Attr.Color = Color.Blue;

                }
                else
                {
                    //for (APSet::element_iterator el_it=ap_set.all_elements_begin();el_it!=ap_set.all_elements_end();++el_it)
                    for (int el_it = ap_set.all_elements_begin(); el_it != ap_set.all_elements_end(); ++el_it)
                    {
                        APElement label = new APElement(el_it);
                        DA_State to_state = cur_state.edges().get(label);
                        int to_state_index = to_state.getName();
                        //out << "\"" << i_state << "\" -> \"" << to_state_index;
                        //out << "\" [label=\" " << label.toString(getAPSet(), false) << "\"]\n";

                        Edge edge = g.AddEdge(stateToNumber[i_state], label.toString(getAPSet(), false), stateToNumber[to_state_index]);
                        //edge.Attr.Color = Color.Blue;
                    }
                }
            }

            return g;
        }