25 pair<DisjSets*, ofstream*> *
mypair = (pair<DisjSets*, ofstream*> *) arg;
27 ofstream * out =
mypair->second;
31int main(
int argc,
char* argv[])
35 cout <<
"Usage: ./cc <vertices_file> <edges_file>" << endl;
39 ifstream inputvert(argv[1]);
45 while(inputvert >> vname)
47 string s_vname(vname);
52 cout <<
"vertex list read, there are " << vertexid << endl;
56 if ((f = fopen(argv[2],
"r")) == NULL)
58 printf(
"file %s can not be found\n", argv[2]);
64 if (stat(argv[2], &st) == -1)
69 cout <<
"Edge file is " << file_size <<
" bytes" << endl;
70 long int ffirst = ftell(f);
71 long int fpos = ffirst;
72 long int end_fpos = file_size;
75 bool finished =
FetchBatch(f, fpos, end_fpos,
true, lines);
76 int64_t entriesread = lines.size();
82 for (vector<string>::iterator itr=lines.begin(); itr != lines.end(); ++itr)
85 sscanf(itr->c_str(),
"%s %s %lg", from, to, &vv);
86 string s_from = string(from);
87 string s_to = string(to);
92 cout <<
"This doesn't make sense! " << s_from <<
" should exist" << endl;
98 cout <<
"This doesn't make sense! " << s_to <<
" should exist" << endl;
100 int set1 = ds.
find((
int) obj1->
vid);
101 int set2 = ds.
find((
int) obj2->
vid);
107 vector<string>().swap(lines);
111 finished =
FetchBatch(f, fpos, end_fpos,
false, lines);
112 entriesread += lines.size();
113 cout <<
"entriesread: " << entriesread <<
", current vertex id: " << vertexid << endl;
119 for (vector<string>::iterator itr=lines.begin(); itr != lines.end(); ++itr)
122 sscanf(itr->c_str(),
"%s %s %lg", from, to, &vv);
124 string s_from = string(from);
125 string s_to = string(to);
130 cout <<
"This doesn't make sense! " << s_from <<
" should exist" << endl;
136 cout <<
"This doesn't make sense! " << s_to <<
" should exist" << endl;
138 int set1 = ds.
find((
int) obj1->
vid);
139 int set2 = ds.
find((
int) obj2->
vid);
145 vector<string>().swap(lines);
147 cout <<
"There are " << vertexid <<
" vertices and " << entriesread <<
" edges" << endl;
149 string s_out(argv[1]);
150 s_out +=
".components";
bool FetchBatch(FILE *f_local, long int &curpos, long int end_fpos, bool firstcall, vector< string > &lines)
int compare(const void *arg, const void *obj)
void * printfunc(void *arg, void *obj)
void unionSets(int root1, int root2)
tommy_uint32_t tommy_hash_u32(tommy_uint32_t init_val, const void *void_key, tommy_size_t key_len)
tommy_inline void * tommy_hashdyn_search(tommy_hashdyn *hashdyn, tommy_search_func *cmp, const void *cmp_arg, tommy_hash_t hash)
void tommy_hashdyn_init(tommy_hashdyn *hashdyn)
void tommy_hashdyn_insert(tommy_hashdyn *hashdyn, tommy_hashdyn_node *node, void *data, tommy_hash_t hash)
void tommy_hashdyn_foreach_arg(tommy_hashdyn *hashdyn, tommy_foreach_arg_func *func, void *arg)
void tommy_foreach_arg_func(void *arg, void *obj)