示例#1
0
        /// <summary>
        /// Add a row to the table and figure out which states are equivalent. Here is a basic rundown of the algorithm: for every vertex of 
        /// the set in your rowNames entry for that row, union all the states that can be reached by the transition designated by that column 
        /// of the table (from any vertex from the rowNames entry). This union of states is what you store in the table.
        /// </summary>
        /// <param name="set">VertexSet that you must check the transitions of</param>
        public void addRow(VertexSet set)
        {
            //declared temporary variables v,e and s to hold individual BaseVertexes, Edges and strings from the foreach loops below
            BaseVertex v;
            Edge e;
            string s;

            //the union of the necessary BaseVertexes to store in the table
            VertexSet tablePayload;

            for(int i=0; i < columnNames.Count; i++){ // for every transition
                s = (string)columnNames[i];
                tablePayload = new VertexSet();
                for(int j=0; j < set.size(); j++){ // for every vertex in the set (the set is the corresponding rowNames entry passed in from the caller)
                    v = (BaseVertex)set.vertices[j];

                    for(int k=0; k < v.Connections.Count; k++){ // for every edge in that vertex
                        e = v.Connections[k];
                        if (e.Condition == s && !tablePayload.isInSet(e.Connection)) { // check if the edge transition is the same as the column you're in and also if it's not already in the tablepayload
                            tablePayload.addToSet(e.Connection);
                        }
                    }
                }
                table[i].Add(eClosure(tablePayload)); // put that payload into the table
            }
        }
示例#2
0
 /// <summary>
 /// Tests the equality of this and another VertexSet
 /// </summary>
 /// <param name="o"> other VertexSet to test against</param>
 /// <returns>true if the VertexSets have the same ID</returns>
 public bool Equals(VertexSet o)
 {
     if (o.id == this.id) {
         return true;
     }
     return false;
 }
示例#3
0
        /// <summary>
        /// perform an epsilon closure on a vertex
        /// </summary>
        /// <param name="v">vertex to perform e closure on</param>
        /// <returns>list of vertices in the epsilon closure of the vertex passed into the method</returns>
        public VertexSet eClosure(BaseVertex v)
        {
            Stack<BaseVertex> nodes = new Stack<BaseVertex>();
            BaseVertex current;
            VertexSet visited = new VertexSet(new ArrayList());

            // if the node passed doesn't have e transitions, return list with just passed in vertex, otherwise push onto stack and start algorithm
            if (this.hasEpsilonTransition(v))
            {
                nodes.Push(v);
            }

            while (nodes.Count > 0)
            {
                current = nodes.Pop();
                visited.addToSet(current);
                if (this.hasEpsilonTransition(current))
                {
                    ArrayList eNodes = this.getEpsilonTransition(current);
                    foreach (BaseVertex newNode in eNodes)
                    {
                        if (!visited.isInSet(newNode))
                        {
                            nodes.Push(newNode);
                        }
                    }
                }
            }
            if (visited.size() == 0)
            {
                visited.addToSet(v);
            }

            return visited;
        }
示例#4
0
        public VertexSet eClosure(VertexSet vs)
        {
            VertexSet union = new VertexSet();
            VertexSet temp = new VertexSet();
            foreach (BaseVertex v in vs.vertices)
            {
                temp = eClosure(v);
                foreach (BaseVertex vert in temp.vertices)
                {
                    if (!union.isInSet(vert))
                    {
                        union.addToSet(vert);
                    }
                }

            }
            return union;
        }