#include "geneorder.h"
#include <algorithm>
+#include <set>
#include <cstdlib>
+#include <iostream>
using namespace std;
std::pair<int,int> longestSequences(const GeneOrder& go){
+ vector<vector<int> > v = robinsonSchensted(go);
+ return pair<int,int>(v[0].size(),v.size());
}
-
-/*
-robSche2 :: [Int] -> [[Int]] -> [[Int]]
-robSche2 [] ys = ys
-robSche2 (x:xs) ys = robSche2 xs $ robSche4 x ys
-
-robSche3 :: Int -> [Int] -> (Maybe Int,[Int])
-robSche3 x ys = let yless = [y | y <- ys, y < x] in
- let ymore = [y | y <- ys, y > x] in
- case ymore of
- [] -> (Nothing, yless++[x])
- (y:ys) -> (Just y, yless++(x:ys))
-
-robSche4 :: Int -> [[Int]] -> [[Int]]
-robSche4 x [] = [[x]]
-robSche4 x (y:ys) = case robSche3 x y of
- (Nothing, y) -> y:ys
- (Just x, y) -> y:robSche4 x ys
-*/
std::vector<std::vector<int> > robinsonSchensted(const GeneOrder& go){
vector<vector<int> > v;
for (GeneOrder::iterator i = go.begin(); i != go.end(); ++i){
}
return v;
}
+
+int countCycles(const GeneOrder& go){
+ int cycles = 0;
+ set<size_t> marked;
+ for (size_t p = 1; p < go.size() - 1; ++p){
+ if (marked.find(p) != marked.end())
+ continue;
+ }
+ return cycles;
+}
+
+std::vector<Component> findComponents(const GeneOrder& go){
+ return vector<Component>();
+}
+
+//TODO: Think of a better than O(n^2) implementation
+std::vector<Interval> findIntervals(const GeneOrder& go){
+ vector<Interval> intervals;
+ for (size_t i = 0; i < go.size() - 1; ++i){
+ size_t f = 0;
+ size_t s = 0;
+ bool found = false;
+ size_t n = 0;
+ for (GeneOrder::iterator g = go.begin(); g != go.end(); ++g, ++n){
+ if (static_cast<size_t>(abs(*g)) == i){
+ f = n;
+ if (*g >= 0)
+ ++f;
+ if (found)
+ break;
+ found = true;
+ }
+ if(static_cast<size_t>(abs(*g)) == i+1){
+ s = n;
+ if (*g < 0)
+ ++s;
+ if (found)
+ break;
+ found = true;
+ }
+ }
+ intervals.push_back(Interval(f,s));
+ }
+ return intervals;
+}