]> ruin.nu Git - germs.git/commitdiff
countCycles implemented and passess test
authorMichael Andreen <harv@ruin.nu>
Tue, 19 Jun 2007 10:36:11 +0000 (10:36 +0000)
committerMichael Andreen <harv@ruin.nu>
Tue, 19 Jun 2007 10:36:11 +0000 (10:36 +0000)
src/genealgorithms.cpp
src/test/genealgorithmstest.cpp

index ec3a92ea1890f1d9e36554e10086ef4e695c06f3..d9d86a3dd8fcb651ce497180b062fa3ddc562612 100644 (file)
@@ -68,7 +68,6 @@ struct FindP{
 std::vector<Interval> findIntervalsAtPoints(const vector<Interval>& intervals){
        vector<Interval> points;
        for (size_t p = 1; p <= intervals.size(); ++p){
-               cout << endl << "Point " << p << " : ";
                size_t f = 0;
                size_t s = 0;
                bool found = false;
@@ -93,7 +92,6 @@ std::vector<Interval> findIntervalsAtPoints(const vector<Interval>& intervals){
                                }
                        }
                }
-               cout << f << ":" << s << endl;
                points.push_back(Interval(f,s));
        }
        return points;
@@ -104,12 +102,12 @@ int countCycles(const GeneOrder& go){
        int cycles = 0;
        set<size_t> marked;
        vector<Interval> intervals = findIntervals(go);
-       vector<Interval> points;
+       vector<Interval> points = findIntervalsAtPoints(intervals);
        for (size_t p = 1; p < go.size(); ++p){
                if (marked.find(p) != marked.end())
                        continue;
                Interval i = intervals[points[p-1].first];
-               while (marked.find(p) != marked.end()){
+               while (marked.find(p) == marked.end()){
                        marked.insert(p);
                        if (i == intervals[points[p-1].first])
                                i = intervals[points[p-1].second];
index 0fca4d2dc032a4e7e7743c76cdcad7cc69419bff..3f57e0fa3e47a246c02a557e7b0fbeea6996bc98 100644 (file)
@@ -24,7 +24,7 @@ class TESTNAME : public CPPUNIT_NS::TestFixture
   CPPUNIT_TEST( testLongestSequences );
   CPPUNIT_TEST( testFindIntervals );
   CPPUNIT_TEST( testFindIntervalsAtPoints );
-  //CPPUNIT_TEST( testCountCycles );
+  CPPUNIT_TEST( testCountCycles );
   CPPUNIT_TEST_SUITE_END();
 
 protected: