-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bafd384
commit f5fd448
Showing
76 changed files
with
12,709 additions
and
331 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// | ||
// Created by ignaciodias on 15/04/24. | ||
// | ||
|
||
#include "DFAToString.h" | ||
#include "../../../auxiliarmethods/CollectionsOperators.h" | ||
|
||
string DFAToString::dfaToString(DeterministicFiniteAutomata dfa) { | ||
string ret = "digraph{\ninic[shape=point];\ninic->"; | ||
ret += "\"" + CollectionsOperators::to_string_set(dfa.getInitialState()) + "\";\n"; | ||
toStringStatesDFA(dfa, ret); | ||
toStringFinalStateDFA(dfa, ret); | ||
ret += "\n}"; | ||
return ret; | ||
} | ||
void DFAToString::toStringStatesDFA(DeterministicFiniteAutomata dfa, string &ret) { | ||
for(const auto& set1 : dfa.getStates()) { | ||
if(set1.empty()) | ||
continue; | ||
for(const auto& set2 : dfa.getStates()) { | ||
if(set2.empty()) | ||
continue; | ||
set<int> label = dfa.calculateWaysToGo(set1, set2); | ||
if(!label.empty()) { | ||
ret += "\"" + CollectionsOperators::to_string_set(set1) + "\" -> \"" + CollectionsOperators::to_string_set(set2) + "\" [label = \""; | ||
for(auto elem : label) | ||
ret += to_string(elem) + ","; | ||
ret.pop_back(); | ||
ret += "\"];\n"; | ||
} | ||
} | ||
} | ||
} | ||
void DFAToString::toStringFinalStateDFA(DeterministicFiniteAutomata dfa, string& ret) { | ||
ret += "\"" + CollectionsOperators::to_string_set_of_sets(dfa.getFinalStates()) + "\" [shape=doublecircle];\n"; | ||
ret.pop_back(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// | ||
// Created by ignaciodias on 15/04/24. | ||
// | ||
|
||
#ifndef TPOB1_DFATOSTRING_H | ||
#define TPOB1_DFATOSTRING_H | ||
#include "../../../automata/dfa/DeterministicFiniteAutomata.h" | ||
|
||
class DFAToString { | ||
public: | ||
static string dfaToString(DeterministicFiniteAutomata dfa); | ||
private: | ||
static void toStringStatesDFA(DeterministicFiniteAutomata dfa, string& ret); | ||
static void toStringFinalStateDFA(DeterministicFiniteAutomata dfa, string& ret); | ||
}; | ||
|
||
|
||
#endif //TPOB1_DFATOSTRING_H |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.