diff c/Motion.cpp @ 188:1435965d8181

work on connected components
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Thu, 01 Dec 2011 19:18:32 -0500
parents aa1061fb9695
children 1116f0a1ff31
line wrap: on
line diff
--- a/c/Motion.cpp	Thu Dec 01 18:13:10 2011 -0500
+++ b/c/Motion.cpp	Thu Dec 01 19:18:32 2011 -0500
@@ -1,10 +1,18 @@
 #include "Motion.hpp"
 #include "cvutils.hpp"
 
+#include "src/TrajectoryDBAccessList.h"
+
 #include "opencv2/core/core.hpp"
 #include "opencv2/highgui/highgui.hpp"
 
-#include "src/TrajectoryDBAccessList.h"
+#include <boost/graph/connected_components.hpp>
+#include <boost/config.hpp>
+
+#include <iostream>
+#include <vector>
+#include <algorithm>
+#include <utility>
 
 using namespace std;
 using namespace cv;
@@ -157,6 +165,18 @@
   }
 }
 
+void FeatureGraph::connectedComponents(const int& lastInstant) {
+  vector<int> component(num_vertices(graph));
+  // int num = connected_components(graph, &component[0]);
+  // todo change the type of the component map http://www.boost.org/doc/libs/1_48_0/libs/graph/doc/connected_components.html
+
+  // cout << "Total number of components: " << num << endl;
+
+  for (unsigned int i = 0; i < component.size(); ++i)
+      cout << "Vertex " << i <<" is in component " << component[i] << endl;
+  cout << endl;
+}
+
 string FeatureGraph::informationString(void) {
   stringstream ss;
   ss << num_vertices(graph) << " vertices, " << num_edges(graph) << " edges";