I have the following values for example:
0 0 0 1 3 2
These values refers to cluster Ids, where the member of the cluster is the index of the vector. Hence we want to get this sort of output:
Cluster 0 -> 0,1,2
Cluster 1 -> 3
Cluster 2 -> 5
Cluster 3 -> 4
I tried the following construct but it doesn't seem to work: What's the way to do it?
#include <iostream>
#include <vector>
#include <fstream>
#include <sstream>
#include <map>
using namespace std;
int main ( int arg_count, char *arg_vec[] ) {
if (arg_count !=2 ) {
cerr << "expected one argument" << endl;
return EXIT_FAILURE;
}
string line;
ifstream myfile (arg_vec[1]);
map <int, vector <int> > CCTagMap;
if (myfile.is_open())
{
// Skip First Line
getline(myfile,line);
while (getline(myfile,line) )
{
stringstream ss(line);
int CcId;
int TagId = -1;
vector <int> Temp;
while (ss >> CcId) {
TagId++;
cout << CcId << "-" << TagId << endl;
# this way to cluster doesn't seem to work
CCTagMap.insert(make_pair(CcId,Temp.push_back(TagId)));
}
}
myfile.close();
}
else { cout << "Unable to open file\n";}
return 0;
}