73 std::vector<int> mark(inn, -1);
74 std::queue<ord_type> active;
84 while(active.empty() ==
false) {
90 for(
ord_type j = inRowPtr[i]; j < inRowPtr[i+1]; ++j) {
100 for(
ord_type i_r = lastSearch; i_r < inn; ++i_r) {
101 if(mark[i_r] == -1) {
113 std::vector<ord_type> compSize(ncc, 0);
114 for(
ord_type i_c = 0; i_c < inn; ++i_c) {
115 if(mark[i_c] == -1) {
116 std::cout <<
"Vertex " << i_c <<
" is untouched,, Exiting!\n";
120 compSize[mark[i_c]]++;
126 for(
ord_type i_l = 0; i_l < ncc; ++i_l) {
127 if(compSize[i_l] > maxSize) {
128 maxSize = compSize[i_l];
135 for(
ord_type i_v = 0; i_v < inn; ++i_v) {
136 if(mark[i_v] == maxId)
142 if(outn != maxSize) {
143 std::cout <<
"The number of vertices in this component: " << outn <<
" does not match the maximum component size: " << maxSize <<
"\n";
151 for(
ord_type ii = 0; ii < inn; ii++) {
153 for(
ord_type j = inRowPtr[ii]; j < inRowPtr[ii+1]; ++j) {
156 std::cout <<
"Neighbor " << v <<
" of " << ii <<
" is found to be absent in the component\n";
159 outColInd[ptr++] = mark[v];
162 outRowPtr[outn] = ptr;
166 if(outn != maxSize) {
167 std::cout <<
"The number of vertices written: " << outn <<
" does not match the maximum component size: " << maxSize <<
"\n";
173 int main(
int argc,
char* argv[])
179 std::ifstream in(argv[1]);
184 while(line[0] ==
'%');
186 std::stringstream ss1(line);
187 ss1 >> nrows >> nrows >> nnzs;
188 std::cout <<
"Number of Rows " << nrows <<
" Number of Columns " << nrows << std::endl;
189 std::vector<bool> diag(nrows,
false);
192 for(
ord_type i = 0; i < nrows+2; i++)
195 while(getline(in, line)) {
197 std::stringstream ss2(line);
209 for(
ord_type j0 = 0; j0 < nrows; j0++)
213 for(
ord_type k = 2; k < nrows+2; k++)
214 rowPtr[k] += rowPtr[k-1];
223 while(line[0] ==
'%');
226 while(getline(in, line)) {
228 std::stringstream ss2(line);
234 colInd[rowPtr[r+1]++] = c;
235 colInd[rowPtr[c+1]++] = r;
242 for(
ord_type i0 = 0; i0 < nrows; i0++)
243 colInd[rowPtr[i0+1]++] = i0;
252 for(
ord_type i1 = 0; i1 < nrows; i1++) {
254 ord_type deg = rowPtr[i1+1] - rowPtr[i1];
257 std::sort(&colInd[rowPtr[i1]], &colInd[rowPtr[i1+1]]);
258 colIndNew[ptr++] = colInd[rowPtr[i1]];
259 prev = colInd[rowPtr[i1]];
260 for(
ord_type j1 = rowPtr[i1]+1; j1 < rowPtr[i1+1]; j1++) {
261 if(colInd[j1] != prev) {
262 colIndNew[ptr++] = colInd[j1];
268 rowPtrNew[i1+1] = ptr;
271 for(
ord_type i2 = 0; i2 < nrows; i2++) {
272 for(
ord_type j2 = rowPtrNew[i2]; j2 < rowPtrNew[i2+1]; ++j2)
273 if(colIndNew[j2] == i2)
276 if(diag[i2] ==
false)
277 std::cout <<
"ROW " << i2 <<
" misses diagonal\n";
280 std::cout << argv[1] <<
" " << nrows <<
" " << ptr <<
" ";
284 nrows, rowPtrNew, colIndNew,
285 newnrows, rowPtr, colInd );
286 ptr = rowPtr[newnrows];
289 for(
ord_type i3 = 0; i3 < nrows; i3++) {
290 deg = rowPtrNew[i3+1] - rowPtrNew[i3];
296 std::ofstream out(argv[2], std::ios::out | std::ios::binary);
297 out.write((
char*)&newnrows,
sizeof(
ord_type));
298 out.write((
char*)&ptr,
sizeof(
ord_type));
300 out.write((
char*)rowPtr,
sizeof(
ord_type)*(newnrows+1));
301 out.write((
char*)colInd,
sizeof(
ord_type)*(ptr));
305 std::cout << newnrows <<
" " << ptr <<
" " << max <<
"\n";
int main(int narg, char **arg)
void findLargestComponent(ord_type seed, ord_type inn, ord_type *inRowPtr, ord_type *inColInd, ord_type &outn, ord_type *outRowPtr, ord_type *outColInd)