X-Git-Url: https://ruin.nu/git/?p=germs.git;a=blobdiff_plain;f=src%2Fgenesorter.cpp;h=8643702250f82ac6b90bbfd08f6b65aaf0e85ee2;hp=40e62e5b8bab62ae58e55fdc85f0c2f7a486380e;hb=8827131c37c21740b5ac8acf6da9ff598de3f166;hpb=148a31960aeb2ba127ef4322a12ae3af28ef2988 diff --git a/src/genesorter.cpp b/src/genesorter.cpp index 40e62e5..8643702 100644 --- a/src/genesorter.cpp +++ b/src/genesorter.cpp @@ -26,16 +26,27 @@ #include "genealgorithms.h" +#include using namespace std; GeneSorter::ActionList GeneSorter::sort(const GeneOrder& go){ - return ActionList(); + ActionList al; + GeneOrder temp(go); + while(countCycles(temp) != temp.size() - 1){ + ActionList safe = safeActions(go); + if (safe.size() > 0){ + safe[0](temp); + al.push_back(safe[0]); + }else + return ActionList(); //TODO: Need to handle other cases here. + } + return al; } GeneSorter::ActionList GeneSorter::safeActions(const GeneOrder& go){ if (countCycles(go) == go.size() - 1) return ActionList(); ActionList al; - al.push_back(SortAction(new ReverseAction(2,3))); + //al.push_back(SortAction(new ReverseAction(2,3))); return al; }