/// <summary>
        /// Edge(s, symbol) - A collection of NfaState which can be shifted from s when accepting symbol
        /// </summary>
        /// <see cref="https://www.cnblogs.com/Ninputer/archive/2011/06/10/2077991.html"/>
        /// <param name="s">the starting state</param>
        /// <param name="symbol">the accepted symbol</param>
        /// <returns>All the states shifted from s</returns>
        public static HashSet <NfaState> Edge(NfaState s, int symbol)
        {
            var resultSet    = new HashSet <NfaState>(s.EdgesToOther.Count);
            var checkingList = new List <NfaEdge>(s.EdgesToOther);

            while (checkingList.Count != 0)
            {
                var toCheck = checkingList[0];
                checkingList.Remove(toCheck);
                if (toCheck.Sym != symbol)
                {
                    continue;
                }

                resultSet.Add(toCheck.Target);
            }

            return(resultSet);
        }
        public static HashSet <NfaState> Closure(NfaState s)
        {
            var closure      = new HashSet <NfaState>(s.EdgesToOther.Count);
            var checkingList = new List <NfaEdge>(s.EdgesToOther);

            while (checkingList.Count != 0)
            {
                var toCheck = checkingList[0];
                checkingList.Remove(toCheck);
                if (toCheck.Sym != NfaEdge.SymEpsilon)
                {
                    continue;
                }

                closure.Add(toCheck.Target);
                checkingList.AddRange(toCheck.Target.EdgesToOther);
            }

            return(closure);
        }
 public NfaEdge(int symbol, NfaState targetState)
 {
     Sym    = symbol;
     Target = targetState;
 }