};
-std::vector<Interval> findIntervalsAtPoints(const vector<Interval>& intervals){
- vector<Interval> points;
- points.push_back(Interval(intervals.size(),intervals.size())); //Dummy interval to match point and index
- for (size_t p = 1; p <= intervals.size(); ++p){
- size_t f = 0;
- size_t s = 0;
- bool found = false;
- size_t n = 0;
- for (vector<Interval>::const_iterator i = intervals.begin(); i != intervals.end(); ++i, ++n){
- if (i->first == p){
- if (!found){
- f = n;
- found = true;
- }else{
- s = n;
- break;
- }
- }
- if (i->second == p){
- if (!found){
- f = n;
- found = true;
- }else{
- s = n;
- break;
- }
- }
- }
- points.push_back(Interval(f,s));
- }
- return points;
-
-}
-
int countCycles(const GeneOrder& go){
int cycles = 0;
set<size_t> marked;
return intervals;
}
+/**
+ * TODO: Think of a better than O(n^2) implementation.
+ * Possibly move to cache result
+ */
+std::vector<Interval> findIntervalsAtPoints(const vector<Interval>& intervals){
+ vector<Interval> points;
+ points.push_back(Interval(intervals.size(),intervals.size())); //Dummy interval to match point and index
+ for (size_t p = 1; p <= intervals.size(); ++p){
+ size_t f = 0;
+ size_t s = 0;
+ bool found = false;
+ size_t n = 0;
+ for (vector<Interval>::const_iterator i = intervals.begin(); i != intervals.end(); ++i, ++n){
+ if (i->first == p){
+ if (!found){
+ f = n;
+ found = true;
+ }else{
+ s = n;
+ break;
+ }
+ }
+ if (i->second == p){
+ if (!found){
+ f = n;
+ found = true;
+ }else{
+ s = n;
+ break;
+ }
+ }
+ }
+ points.push_back(Interval(f,s));
+ }
+ return points;
+
+}