some fix bugs
This commit is contained in:
parent
aad17d8c8c
commit
0947eeac5d
|
@ -51,6 +51,7 @@ void DFAGraph::RemoveVertex(size_t number) {
|
|||
RemoveFinalVertex(number);
|
||||
RemoveStartVertex(number);
|
||||
vertexes_.erase(number);
|
||||
if (number == count_vertexes_ - 1) count_vertexes_--;
|
||||
}
|
||||
|
||||
void DFAGraph::RemoveFinalVertex(size_t number) {
|
||||
|
|
|
@ -10,6 +10,7 @@ DFAGraph DFAGraphToMinDFAGraph(DFAGraph&& graph) {
|
|||
{
|
||||
std::set<char> set_alphabet;
|
||||
for (int i = 0; i < n; ++i) {
|
||||
if (!graph.GetVertex(i)) continue;
|
||||
for (auto i: graph.GetVertex(i)->GetTransitions()) {
|
||||
set_alphabet.insert(i.first);
|
||||
}
|
||||
|
|
18
src/main.cpp
18
src/main.cpp
|
@ -50,17 +50,21 @@ void example2() {
|
|||
}
|
||||
|
||||
int main() {
|
||||
|
||||
{
|
||||
RegularTree r("a*");
|
||||
RegularTree r("(a|b)+bab(a|b)+");
|
||||
NFAGraph NFA_tree = RegularToNFAGraph(std::move(r));
|
||||
DFAGraph DFA_graph = NFAGraphToDFAGraph(std::move(NFA_tree));
|
||||
DFA_graph = DFAGraphToMinDFAGraph(std::move(DFA_graph));
|
||||
|
||||
DFA_graph = DFAGraphToFDFAGraph(std::move(DFA_graph), {'a', 'b', 'c', 'd'});
|
||||
DFA_graph.Print();
|
||||
DFA_graph = DFAGraphToFDFAGraph(std::move(DFA_graph), {'a', 'b'});
|
||||
DFA_graph = InvertFDFAGraph(std::move(DFA_graph));
|
||||
return 0;
|
||||
DFA_graph = DFAGraphToMinDFAGraph(std::move(DFA_graph));
|
||||
DFA_graph.Print();
|
||||
auto s = DFAGraphToRegular(std::move(DFA_graph));
|
||||
std::cout << s << std::endl;
|
||||
r = RegularTree(s);
|
||||
r.Print();
|
||||
}
|
||||
return 0;
|
||||
RegularTree r("a*");
|
||||
|
@ -74,6 +78,8 @@ int main() {
|
|||
dfa = DFAGraphToMinDFAGraph(std::move(fdfa));
|
||||
auto s = DFAGraphToRegular(std::move(dfa));
|
||||
|
||||
// RegularTree r("(a|b)+bab(a|b)+");
|
||||
// std::cout << DFAGraphToRegular(DFAGraphToMinDFAGraph(InvertFDFAGraph(DFAGraphToFDFAGraph(DFAGraphToMinDFAGraph(NFAGraphToDFAGraph(RegularToNFAGraph(std::move(r)))), {'a', 'b'})))) << std::endl;
|
||||
/*
|
||||
RegularTree r("(a|b)+bab(a|b)+");
|
||||
std::cout << DFAGraphToRegular(DFAGraphToMinDFAGraph(InvertFDFAGraph(DFAGraphToFDFAGraph(DFAGraphToMinDFAGraph(NFAGraphToDFAGraph(RegularToNFAGraph(std::move(r)))), {'a', 'b'})))) << std::endl;
|
||||
*/
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue