@@ -133,7 +133,7 @@ bool readLine (FILE * ifile, int * src, int * dst, T * val, bool binaryformat=tr
133
133
}
134
134
135
135
template <typename T>
136
- void get_maxid_and_nnz (FILE* fp, int * m, int * n, unsigned long int * nnz, bool * symmetric, bool binaryformat=true , bool header=true , bool edgeweights=true ) {
136
+ void get_maxid_and_nnz (FILE* fp, int * m, int * n, unsigned long int * nnz, bool * symmetric, bool *pattern, bool binaryformat=true , bool header=true , bool edgeweights=true ) {
137
137
if (header) {
138
138
int tmp_[3 ];
139
139
if (binaryformat) {
@@ -151,6 +151,8 @@ void get_maxid_and_nnz(FILE* fp, int* m, int* n, unsigned long int* nnz, bool* s
151
151
position = ftell (fp);
152
152
fgets (line, 256 , fp);
153
153
*symmetric = strstr (line, " symmetric" ) != NULL ;
154
+ *pattern = strstr (line, " pattern" ) != NULL ;
155
+ edgeweights = *pattern;
154
156
155
157
// skip all the comments
156
158
line[0 ] = ' %' ;
@@ -266,7 +268,7 @@ void load_edgelist(const char* dir, edgelist_t<T>* edgelist, bool single=true,
266
268
edgelist->m = 0 ;
267
269
edgelist->n = 0 ;
268
270
edgelist->nnz = 0 ;
269
- bool symmetric;
271
+ bool symmetric, pattern ;
270
272
for (int i = global_myrank ; ; i += global_nrank)
271
273
{
272
274
std::stringstream fname_ss;
@@ -287,7 +289,7 @@ void load_edgelist(const char* dir, edgelist_t<T>* edgelist, bool single=true,
287
289
288
290
int m_, n_;
289
291
unsigned long nnz_;
290
- get_maxid_and_nnz<T>(fp, &m_, &n_, &nnz_, &symmetric, binaryformat, header, edgeweights);
292
+ get_maxid_and_nnz<T>(fp, &m_, &n_, &nnz_, &symmetric, &pattern, binaryformat, header, edgeweights);
291
293
edgelist->m = std::max (m_, edgelist->m );
292
294
edgelist->n = std::max (n_, edgelist->n );
293
295
edgelist->nnz += nnz_;
@@ -304,7 +306,7 @@ void load_edgelist(const char* dir, edgelist_t<T>* edgelist, bool single=true,
304
306
edgelist->m = max_m;
305
307
edgelist->n = max_n;
306
308
307
- std::cout << (symmetric ? " Undirected graph " : " Directed graph " ) << std::endl;
309
+ std::cout << (symmetric ? " Undirected " : " Directed " ) << (pattern ? " Unweighted " : " Weighted " ) << std::endl;
308
310
std::cout << " Got: " << edgelist->m << " by " << edgelist->n << " vertices" << std::endl;
309
311
std::cout << " Got: " << edgelist->nnz << " edges" << std::endl;
310
312
@@ -330,14 +332,14 @@ void load_edgelist(const char* dir, edgelist_t<T>* edgelist, bool single=true,
330
332
if (header) { // remove header
331
333
int m_, n_;
332
334
unsigned long nnz_;
333
- get_maxid_and_nnz<T>(fp, &m_, &n_, &nnz_, &symmetric, binaryformat, header, edgeweights);
335
+ get_maxid_and_nnz<T>(fp, &m_, &n_, &nnz_, &symmetric, &pattern, binaryformat, header, edgeweights);
334
336
}
335
337
int j = 0 ;
336
338
while (true ) {
337
339
if (feof (fp)) {
338
340
break ;
339
341
}
340
- if (!readLine<T>(fp, &(edgelist->edges [nnzcnt].src ), &(edgelist->edges [nnzcnt].dst ), &(edgelist->edges [nnzcnt].val ), binaryformat, edgeweights)) {
342
+ if (!readLine<T>(fp, &(edgelist->edges [nnzcnt].src ), &(edgelist->edges [nnzcnt].dst ), &(edgelist->edges [nnzcnt].val ), binaryformat, !pattern && edgeweights)) {
341
343
break ;
342
344
}
343
345
#ifdef __DEBUG
0 commit comments