Skip to content

Commit

Permalink
fix in binary reader
Browse files Browse the repository at this point in the history
  • Loading branch information
Julian Shun committed Mar 16, 2016
1 parent f1ed257 commit c996d8a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions apps/Triangle.C
Original file line number Diff line number Diff line change
Expand Up @@ -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 <class vertex>
Expand Down
19 changes: 4 additions & 15 deletions ligra/IO.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include <cmath>
#include "parallel.h"
#include "blockRadixSort.h"
#include "quickSort.h"
#include "utils.h"
#include "graph.h"
using namespace std;
Expand Down Expand Up @@ -216,11 +215,8 @@ graph<vertex> readGraphFromFile(char* fname, bool isSymmetric) {
free(offsets);

#ifndef WEIGHTED
//quickSort(temp,m,pairFirstCmp<uintE>());
intSort::iSort(temp,m,n+1,getFirst<uintE>());

#else
//quickSort(temp,m,pairFirstCmp<intPair>());
intSort::iSort(temp,m,n+1,getFirst<intPair>());
#endif

Expand Down Expand Up @@ -296,7 +292,11 @@ graph<vertex> 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();
Expand All @@ -322,7 +322,6 @@ graph<vertex> readGraphFromBinary(char* iFile, bool isSymmetric) {
}}
//free(edges);
#endif

{parallel_for(long i=0;i<n;i++) {
uintT o = offsets[i];
uintT l = ((i==n-1) ? m : offsets[i+1])-offsets[i];
Expand All @@ -333,7 +332,6 @@ graph<vertex> 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<n;i++) tOffsets[i] = INT_T_MAX;}
Expand All @@ -352,21 +350,14 @@ graph<vertex> 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<uintE>());

#ifndef WEIGHTED
//quickSort(temp,m,pairFirstCmp<uintE>());
intSort::iSort(temp,m,n+1,getFirst<uintE>());

#else
//quickSort(temp,m,pairFirstCmp<intPair>());
intSort::iSort(temp,m,n+1,getFirst<intPair>());
#endif

tOffsets[temp[0].first] = 0;
#ifndef WEIGHTED
inEdges[0] = temp[0].second;
Expand All @@ -386,11 +377,9 @@ graph<vertex> 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>(),(uintT)m);

{parallel_for(long i=0;i<n;i++){
uintT o = tOffsets[i];
uintT l = ((i == n-1) ? m : tOffsets[i+1])-tOffsets[i];
Expand Down

0 comments on commit c996d8a

Please sign in to comment.