From c996d8a93b23e6acce673c901141333e53291d49 Mon Sep 17 00:00:00 2001 From: Julian Shun Date: Wed, 16 Mar 2016 04:15:59 -0400 Subject: [PATCH] fix in binary reader --- README.md | 2 +- apps/Triangle.C | 1 + ligra/IO.h | 19 ++++--------------- 3 files changed, 6 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 3b646ef..77ead0e 100644 --- a/README.md +++ b/README.md @@ -332,7 +332,7 @@ a bitvector to mark visited vertices), **BC.C** (betweenness centrality), **Radii.C** (graph eccentricity estimation), **Components.C** (connected components), **BellmanFord.C** (Bellman-Ford shortest paths), **PageRank.C**, **PageRankDelta.C**, -**BFSCC.C** (connected components based on BFS), **MIS.C** (maximal independent set), and **KCore.C** (K-core decomposition). +**BFSCC.C** (connected components based on BFS), **MIS.C** (maximal independent set), **KCore.C** (K-core decomposition), and *Triangle.C** (triangle counting). Eccentricity Estimation diff --git a/apps/Triangle.C b/apps/Triangle.C index 5b62fb3..37c7328 100644 --- a/apps/Triangle.C +++ b/apps/Triangle.C @@ -28,6 +28,7 @@ // Tuning", ICDE 2015. Currently only works with uncompressed graphs, // and not with compressed graphs. #include "ligra.h" +#include "quickSort.h" //assumes sorted neighbor lists template diff --git a/ligra/IO.h b/ligra/IO.h index c13e0bf..6976e46 100644 --- a/ligra/IO.h +++ b/ligra/IO.h @@ -27,7 +27,6 @@ #include #include "parallel.h" #include "blockRadixSort.h" -#include "quickSort.h" #include "utils.h" #include "graph.h" using namespace std; @@ -216,11 +215,8 @@ graph readGraphFromFile(char* fname, bool isSymmetric) { free(offsets); #ifndef WEIGHTED - //quickSort(temp,m,pairFirstCmp()); intSort::iSort(temp,m,n+1,getFirst()); - #else - //quickSort(temp,m,pairFirstCmp()); intSort::iSort(temp,m,n+1,getFirst()); #endif @@ -296,7 +292,11 @@ graph readGraphFromBinary(char* iFile, bool isSymmetric) { in2.seekg(0, ios::end); long size = in2.tellg(); in2.seekg(0); +#ifdef WEIGHTED long m = size/(2*sizeof(uint)); +#else + long m = size/sizeof(uint); +#endif char* s = (char *) malloc(size); in2.read(s,size); in2.close(); @@ -322,7 +322,6 @@ graph readGraphFromBinary(char* iFile, bool isSymmetric) { }} //free(edges); #endif - {parallel_for(long i=0;i readGraphFromBinary(char* iFile, bool isSymmetric) { v[i].setOutNeighbors(edgesAndWeights+2*o); #endif }} - if(!isSymmetric) { uintT* tOffsets = newA(uintT,n); {parallel_for(long i=0;i readGraphFromBinary(char* iFile, bool isSymmetric) { #else temp[o+j] = make_pair(v[i].getOutNeighbor(j),make_pair(i,v[i].getOutWeight(j))); #endif - //temp[o+j] = make_pair(v[i].getOutNeighbor(j),i); } }} free(offsets); - //quickSort(temp,m,pairFirstCmp()); - #ifndef WEIGHTED - //quickSort(temp,m,pairFirstCmp()); intSort::iSort(temp,m,n+1,getFirst()); - #else - //quickSort(temp,m,pairFirstCmp()); intSort::iSort(temp,m,n+1,getFirst()); #endif - tOffsets[temp[0].first] = 0; #ifndef WEIGHTED inEdges[0] = temp[0].second; @@ -386,11 +377,9 @@ graph readGraphFromBinary(char* iFile, bool isSymmetric) { } }} free(temp); - //fill in offsets of degree 0 vertices by taking closest non-zero //offset to the right sequence::scanIBack(tOffsets,tOffsets,n,minF(),(uintT)m); - {parallel_for(long i=0;i