diff --git a/src/graphRegex/matchFsm/FsmGraph.cpp b/src/graphRegex/matchFsm/FsmGraph.cpp index 09bc25d636c1cc882439f50107bf728714fdfb20..5a9f00d728cd2cd9f58c2228361f8393de2a3d9d 100644 --- a/src/graphRegex/matchFsm/FsmGraph.cpp +++ b/src/graphRegex/matchFsm/FsmGraph.cpp @@ -1,6 +1,6 @@ #include "aidge/graphRegex/matchFsm/FsmGraph.hpp" -using namespace Aidge; +using namespace Aidge; @@ -14,7 +14,7 @@ FsmGraph::FsmGraph(/* args */){ if(startNodes.size() != startNodesFsm.size()){ throw std::runtime_error("bad number of Start nodes"); } - + std::vector<std::shared_ptr<FsmRunTimeContext>> walks; for(std::size_t i = 0; i < startNodes.size(); i++){ walks.push_back(std::make_shared<FsmRunTimeContext>(startNodesFsm[i],startNodes[i])); @@ -32,16 +32,16 @@ FsmGraph::FsmGraph(/* args */){ for(auto fsmContext : walks){ allContextSee.push_back(fsmContext); //if we are in a valid st we save it - //it's one solution of the posible solution of the matching + //it's one solution of the posible solution of the matching if(fsmContext->isOnValidState()){ - //not save 2 time the same end point + //not save 2 time the same end point if(!std::any_of(allValidContext.begin(), allValidContext.end(), [&](std::shared_ptr<Aidge::FsmRunTimeContext> oldValid) { return fsmContext->areEqual(oldValid); })){ allValidContext.push_back(fsmContext); } - + } //dont test 2 time a fsmContext @@ -60,15 +60,15 @@ FsmGraph::FsmGraph(/* args */){ walks.swap(nextWalks); nextWalks.clear(); } - - + + return std::make_shared<MatchResult>(allValidContext,getNbSubFsm()); } /////////////// -// FSM construction +// FSM construction /////////////// const std::set<std::shared_ptr<FsmEdge>>& FsmGraph::getEdge(void){ return mEdges; @@ -140,7 +140,7 @@ void FsmGraph::mergeOneStartOneValid(const std::shared_ptr<FsmGraph> fsmGraph){ } unionG(fsmGraph); - //for loop useless but for future merge it's coudl be used + //for loop useless but for future merge it's coudl be used for(auto valid : validNodes){ valid->unValid(); for(auto start : startNodes){ @@ -159,9 +159,11 @@ void FsmGraph::incOrigineAllNodeBy(std::size_t incr){ for(auto node :nodes){ node->incOrigine(incr); } + std::set<std::size_t> updatedOrigin; for(auto origin : mAllOrigine){ - origin += incr; + updatedOrigin.insert(origin + incr); } + mAllOrigine.swap(updatedOrigin); } void FsmGraph::_mergeNode(std::shared_ptr<FsmNode> source,std::shared_ptr<FsmNode> dest){ @@ -189,7 +191,7 @@ void FsmGraph::_mergeNode(std::shared_ptr<FsmNode> source,std::shared_ptr<FsmNod } } - //check is source is not in graph + //check is source is not in graph nodes = getNodes(); if(nodes.find(source) != nodes.end() ){ throw std::runtime_error("FsmGraph merge node not effective");