diff --git a/alib2algo/src/automaton/simplify/MinimizeVerbose.cpp b/alib2algo/src/automaton/simplify/MinimizeVerbose.cpp index f59f1c9992406f22ccb1a280c43175d383fe55fc..c857089fecd2331066bb7ecaf5a3eba60504c0e6 100644 --- a/alib2algo/src/automaton/simplify/MinimizeVerbose.cpp +++ b/alib2algo/src/automaton/simplify/MinimizeVerbose.cpp @@ -3,7 +3,7 @@ namespace { -auto MinimizeVerboseNFA = registration::AbstractRegister < automaton::simplify::MinimizeVerbose, ext::vector < ext::map < std::pair < DefaultStateType, DefaultStateType >, ext::map < DefaultSymbolType, DefaultStateType > > >, const automaton::DFA < > & > ( automaton::simplify::MinimizeVerbose::minimize, "dfa" ).setDocumentation ( +auto MinimizeVerboseNFA = registration::AbstractRegister < automaton::simplify::MinimizeVerbose, ext::vector < ext::map < ext::pair < DefaultStateType, DefaultStateType >, ext::map < DefaultSymbolType, DefaultStateType > > >, const automaton::DFA < > & > ( automaton::simplify::MinimizeVerbose::minimize, "dfa" ).setDocumentation ( "Minimizes deterministic finite autmaton, also reports the middle steps of the computation.\n\ \n\ @param dfa deterministic finite automaton to minimize.\n\ diff --git a/alib2algo/src/automaton/simplify/MinimizeVerbose.h b/alib2algo/src/automaton/simplify/MinimizeVerbose.h index cc70461d4906b38c635c69b1ba73c9c915ca36be..53f12d34b0d6fef83c69610ceabe631965fa6787 100644 --- a/alib2algo/src/automaton/simplify/MinimizeVerbose.h +++ b/alib2algo/src/automaton/simplify/MinimizeVerbose.h @@ -52,16 +52,16 @@ public: * @return trace of minimisation of the automaton */ template < class SymbolType, class StateType > - static ext::vector < ext::map < std::pair < StateType, StateType >, ext::map < SymbolType, StateType > > > minimize(const automaton::DFA < SymbolType, StateType >& dfa ); + static ext::vector < ext::map < ext::pair < StateType, StateType >, ext::map < SymbolType, StateType > > > minimize(const automaton::DFA < SymbolType, StateType >& dfa ); private: template < class SymbolType, class StateType > - static ext::map < std::pair < StateType, StateType >, ext::map < SymbolType, StateType > > print_progress ( const ext::map<std::pair<StateType, ext::set<std::pair<SymbolType, StateType> > >, ext::set<StateType> >& minimizedTransitionFunction); + static ext::map < ext::pair < StateType, StateType >, ext::map < SymbolType, StateType > > print_progress ( const ext::map<ext::pair<StateType, ext::set<ext::pair<SymbolType, StateType> > >, ext::set<StateType> >& minimizedTransitionFunction); }; template < class SymbolType, class StateType > -ext::vector < ext::map < std::pair < StateType, StateType >, ext::map < SymbolType, StateType > > > MinimizeVerbose::minimize(const automaton::DFA < SymbolType, StateType >& dfa ) { - ext::vector < ext::map < std::pair < StateType, StateType >, ext::map < SymbolType, StateType > > > res; +ext::vector < ext::map < ext::pair < StateType, StateType >, ext::map < SymbolType, StateType > > > MinimizeVerbose::minimize(const automaton::DFA < SymbolType, StateType >& dfa ) { + ext::vector < ext::map < ext::pair < StateType, StateType >, ext::map < SymbolType, StateType > > > res; ext::map<StateType, ext::map<SymbolType, StateType > > refactor; @@ -72,7 +72,7 @@ ext::vector < ext::map < std::pair < StateType, StateType >, ext::map < SymbolTy refactor[transition.first.first].insert(std::make_pair(transition.first.second, transition.second)); ext::map<StateType, StateType> toEquivalentStates; //original state to equivalent state - ext::map<std::pair<StateType, ext::set<std::pair<SymbolType, StateType> > >, ext::set<StateType> > minimizedTransitionFunction; //mapped to the original state + ext::map<ext::pair<StateType, ext::set<ext::pair<SymbolType, StateType> > >, ext::set<StateType> > minimizedTransitionFunction; //mapped to the original state const StateType *firstFinal = nullptr; const StateType *firstNonfinal = nullptr; @@ -92,12 +92,12 @@ ext::vector < ext::map < std::pair < StateType, StateType >, ext::map < SymbolTy while ( true ) { for(const std::pair<const StateType, ext::map<SymbolType, StateType> >& transition : refactor) { const StateType& from = toEquivalentStates.find(transition.first)->second; - ext::set<std::pair<SymbolType, StateType> > transitionFunction; + ext::set<ext::pair<SymbolType, StateType> > transitionFunction; for(const std::pair<const SymbolType, StateType> & transitionFromState : transition.second) - transitionFunction.insert(std::make_pair(transitionFromState.first, toEquivalentStates.find(transitionFromState.second)->second)); + transitionFunction.insert(ext::make_pair(transitionFromState.first, toEquivalentStates.find(transitionFromState.second)->second)); - minimizedTransitionFunction[std::make_pair(from, transitionFunction)].insert(transition.first); + minimizedTransitionFunction[ext::make_pair(from, transitionFunction)].insert(transition.first); } res.push_back ( print_progress ( minimizedTransitionFunction) ); @@ -108,7 +108,7 @@ ext::vector < ext::map < std::pair < StateType, StateType >, ext::map < SymbolTy prevSize = minimizedTransitionFunction.size(); toEquivalentStates.clear(); - for(const std::pair<const std::pair<StateType, ext::set<std::pair<SymbolType, StateType> > >, ext::set<StateType> >& transition : minimizedTransitionFunction) + for(const std::pair<const ext::pair<StateType, ext::set < ext::pair<SymbolType, StateType> > >, ext::set<StateType> >& transition : minimizedTransitionFunction) for(const StateType& target : transition.second) toEquivalentStates.insert(std::make_pair(target, *(transition.second.begin()))); @@ -121,17 +121,17 @@ ext::vector < ext::map < std::pair < StateType, StateType >, ext::map < SymbolTy #define RESETSS(x) {(x).clear(); (x).str("");} template < class SymbolType, class StateType > -ext::map<std::pair<StateType, StateType>, ext::map<SymbolType, StateType>> MinimizeVerbose::print_progress ( const ext::map<std::pair<StateType, ext::set<std::pair<SymbolType, StateType> > >, ext::set<StateType> >& minimizedTransitionFunction) { +ext::map<ext::pair<StateType, StateType>, ext::map<SymbolType, StateType>> MinimizeVerbose::print_progress ( const ext::map<ext::pair<StateType, ext::set<ext::pair<SymbolType, StateType> > >, ext::set<StateType> >& minimizedTransitionFunction) { /* need to restruct this first so we have table like: orig state | new state | trans_symb_1 | trans_symb_2 | ... | trans_symb_n */ // we surely have DFA here (transition map hence) - ext::map<std::pair<StateType, StateType>, ext::map<SymbolType, StateType>> printMap; + ext::map<ext::pair<StateType, StateType>, ext::map<SymbolType, StateType>> printMap; for(const auto& kv: minimizedTransitionFunction) { for(const auto& state : kv.second) { ext::map<SymbolType, StateType> stateTransMap; for(const auto& transition : kv.first.second) { stateTransMap.insert(std::make_pair(transition.first, transition.second)); } - printMap.insert(std::make_pair(std::make_pair(state, kv.first.first), stateTransMap)); + printMap.insert(std::make_pair(ext::make_pair(state, kv.first.first), stateTransMap)); } } return printMap; diff --git a/alib2graph_algo/src/minimum_cut/FordFulkerson.cpp b/alib2graph_algo/src/minimum_cut/FordFulkerson.cpp index 2d77c97847c2f1db6c8bf9886f5fc7538f7b03c6..aa386216a4c639a0c64c17963cb6a420f6f26986 100644 --- a/alib2graph_algo/src/minimum_cut/FordFulkerson.cpp +++ b/alib2graph_algo/src/minimum_cut/FordFulkerson.cpp @@ -43,7 +43,7 @@ static Cut fordfulkerson_impl_dir(const DirectedGraph &graph, // mark nodes, which are reachable from source ext::unordered_map<node::Node, int> state; std::queue<node::Node> open; - ext::vector<std::pair<node::Node, node::Node>> candidates; + ext::vector<ext::pair<node::Node, node::Node>> candidates; for (const node::Node &node : graph.getNodes()) state[node] = 0; state[source] = 1; @@ -70,7 +70,7 @@ static Cut fordfulkerson_impl_dir(const DirectedGraph &graph, } // cut are those edges, which lead from nodes reachable from source to nodes unreachable from source - for (const std::pair<node::Node, node::Node> & edge : candidates) { + for (const ext::pair<node::Node, node::Node> & edge : candidates) { if ((state[edge.first] == 1 && state[edge.second] == 0) || (state[edge.first] == 0 && state[edge.second] == 1)) cut.insert(edge); @@ -91,7 +91,7 @@ static Cut fordfulkerson_impl_undir(const UndirectedGraph &ugraph, // mark nodes, which are reachable from source ext::unordered_map<node::Node, int> state; std::queue<node::Node> open; - ext::vector<std::pair<node::Node, node::Node>> candidates; + ext::vector<ext::pair<node::Node, node::Node>> candidates; for (const node::Node &node : ugraph.getNodes()) state[node] = 0; state[source] = 1; @@ -110,7 +110,7 @@ static Cut fordfulkerson_impl_undir(const UndirectedGraph &ugraph, } // cut are those edges, which lead from nodes reachable from source to nodes unreachable from source - for (const std::pair<node::Node, node::Node> & edge : candidates) { + for (const ext::pair<node::Node, node::Node> & edge : candidates) { if ((state[edge.first] == 1 && state[edge.second] == 0) || (state[edge.first] == 0 && state[edge.second] == 1)) cut.insert(edge); diff --git a/alib2graph_algo/src/minimum_cut/FordFulkerson.hpp b/alib2graph_algo/src/minimum_cut/FordFulkerson.hpp index 87a4405b74f2adbda3325ea6946bada627194333..80951a7616eae3ffdeb6534666c453191830ae89 100644 --- a/alib2graph_algo/src/minimum_cut/FordFulkerson.hpp +++ b/alib2graph_algo/src/minimum_cut/FordFulkerson.hpp @@ -10,8 +10,8 @@ namespace std { template<> -struct hash<std::pair<node::Node, node::Node> > { - std::size_t operator()(const std::pair<node::Node, node::Node> &p) const { +struct hash<ext::pair<node::Node, node::Node> > { + std::size_t operator()(const ext::pair<node::Node, node::Node> &p) const { return std::hash<std::string>()(ext::to_string(p.first) + ext::to_string(p.second)); } }; @@ -23,7 +23,7 @@ namespace graph { namespace minimum_cut { -typedef ext::unordered_set<std::pair<node::Node, node::Node> > Cut; +typedef ext::unordered_set<ext::pair<node::Node, node::Node> > Cut; // Old implementation without templates using UndirectedGraph = graph::UndirectedGraph<node::Node, edge::CapacityEdge<node::Node, int>>; diff --git a/alib2graph_algo/test-src/minimum_cut/FordFulkersonTest.cpp b/alib2graph_algo/test-src/minimum_cut/FordFulkersonTest.cpp index cf211701bc73905a8fc4bc05c1ee70616196dbc7..e475ea3c29524a691f562d01e1bb8b46dce2b4db 100644 --- a/alib2graph_algo/test-src/minimum_cut/FordFulkersonTest.cpp +++ b/alib2graph_algo/test-src/minimum_cut/FordFulkersonTest.cpp @@ -126,7 +126,7 @@ void testDirNetwork(unsigned netID, const Type1 *netDef, const Type2 cutDef, uns CHECK ( cutSize == cut.size ( ) ); for (i = 0; i < cutSize; i++) { - CHECK(cut.find(std::make_pair(id2node[cutDef[i].node1ID], id2node[cutDef[i].node2ID])) != cut.end()); + CHECK(cut.find(ext::make_pair(id2node[cutDef[i].node1ID], id2node[cutDef[i].node2ID])) != cut.end()); } } @@ -156,7 +156,7 @@ void testUndirNetwork(unsigned netID, const Type1 *netDef, const Type2 cutDef, u CHECK (cutSize == cut.size ( ) ); for (i = 0; i < cutSize; i++) { - CHECK(cut.find(std::make_pair(id2node[cutDef[i].node1ID], id2node[cutDef[i].node2ID])) != cut.end()); + CHECK(cut.find(ext::make_pair(id2node[cutDef[i].node1ID], id2node[cutDef[i].node2ID])) != cut.end()); } }