From 6724d50f2d36dccd383d95d36f7fe328b2692bc0 Mon Sep 17 00:00:00 2001 From: Michael Andreen Date: Tue, 19 Jun 2007 10:36:11 +0000 Subject: [PATCH] countCycles implemented and passess test --- src/genealgorithms.cpp | 6 ++---- src/test/genealgorithmstest.cpp | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/genealgorithms.cpp b/src/genealgorithms.cpp index ec3a92e..d9d86a3 100644 --- a/src/genealgorithms.cpp +++ b/src/genealgorithms.cpp @@ -68,7 +68,6 @@ struct FindP{ std::vector findIntervalsAtPoints(const vector& intervals){ vector 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 findIntervalsAtPoints(const vector& 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 marked; vector intervals = findIntervals(go); - vector points; + vector 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]; diff --git a/src/test/genealgorithmstest.cpp b/src/test/genealgorithmstest.cpp index 0fca4d2..3f57e0f 100644 --- a/src/test/genealgorithmstest.cpp +++ b/src/test/genealgorithmstest.cpp @@ -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: -- 2.39.2