Skip to content

Commit

Permalink
fix in symmetrization process
Browse files Browse the repository at this point in the history
  • Loading branch information
jshun committed Sep 24, 2014
1 parent 1df1306 commit 224352e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 24 deletions.
42 changes: 18 additions & 24 deletions IO.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ graph<vertex> readGraphFromFile(char* fname, bool isSymmetric) {

quickSort(temp,m,pairFirstCmp<intE>());

tOffsets[0] = 0; inEdges[0] = temp[0].second;
tOffsets[temp[0].first] = 0; inEdges[0] = temp[0].second;
{parallel_for(intT i=1;i<m;i++) {
inEdges[i] = temp[i].second;
if(temp[i].first != temp[i-1].first) {
Expand All @@ -159,11 +159,10 @@ graph<vertex> readGraphFromFile(char* fname, bool isSymmetric) {
}}
free(temp);

uintT currOffset = m;
for(intT i=n-1;i>=0;i--) {
if(tOffsets[i] == INT_T_MAX) tOffsets[i] = currOffset;
else currOffset = tOffsets[i];
}

//fill in offsets of degree 0 vertices by taking closest non-zero
//offset to the right
sequence::scanIBack(tOffsets,tOffsets,n,minF<intT>(),(intT)m);

{parallel_for(uintT i=0;i<n;i++){
uintT o = tOffsets[i];
Expand Down Expand Up @@ -233,7 +232,7 @@ wghGraph<vertex> readWghGraphFromFile(char* fname, bool isSymmetric) {

quickSort(temp,m,pairFirstCmp<intPair>());

tOffsets[0] = 0;
tOffsets[temp[0].first] = 0;
inEdgesAndWghs[0] = temp[0].second.first;
inEdgesAndWghs[1] = temp[0].second.second;
{parallel_for(intT i=1;i<m;i++) {
Expand All @@ -246,11 +245,9 @@ wghGraph<vertex> readWghGraphFromFile(char* fname, bool isSymmetric) {

free(temp);

uintT currOffset = m;
for(intT i=n-1;i>=0;i--) {
if(tOffsets[i] == INT_T_MAX) tOffsets[i] = currOffset;
else currOffset = tOffsets[i];
}
//fill in offsets of degree 0 vertices by taking closest non-zero
//offset to the right
sequence::scanIBack(tOffsets,tOffsets,n,minF<intT>(),(intT)m);

{parallel_for(uintT i=0;i<n;i++){
uintT o = tOffsets[i];
Expand Down Expand Up @@ -336,7 +333,7 @@ graph<vertex> readGraphFromBinary(char* iFile, bool isSymmetric) {

quickSort(temp,m,pairFirstCmp<intE>());

tOffsets[0] = 0; inEdges[0] = temp[0].second;
tOffsets[temp[0].first] = 0; inEdges[0] = temp[0].second;
{parallel_for(intT i=1;i<m;i++) {
inEdges[i] = temp[i].second;
if(temp[i].first != temp[i-1].first) {
Expand All @@ -345,11 +342,9 @@ graph<vertex> readGraphFromBinary(char* iFile, bool isSymmetric) {
}}
free(temp);

uintT currOffset = m;
for(intT i=n-1;i>=0;i--) {
if(tOffsets[i] == INT_T_MAX) tOffsets[i] = currOffset;
else currOffset = tOffsets[i];
}
//fill in offsets of degree 0 vertices by taking closest non-zero
//offset to the right
sequence::scanIBack(tOffsets,tOffsets,n,minF<intT>(),(intT)m);

{parallel_for(uintT i=0;i<n;i++){
uintT o = tOffsets[i];
Expand Down Expand Up @@ -438,7 +433,7 @@ wghGraph<vertex> readWghGraphFromBinary(char* iFile, bool isSymmetric) {
free(offsets);
quickSort(temp,m,pairFirstCmp<intE>());

tOffsets[0] = 0;
tOffsets[temp[0].first] = 0;
inEdgesAndWghs[0] = temp[0].second;
inEdgesAndWghs[1] = 1;
{parallel_for(intT i=1;i<m;i++) {
Expand All @@ -449,11 +444,10 @@ wghGraph<vertex> readWghGraphFromBinary(char* iFile, bool isSymmetric) {
}
}}
free(temp);
uintT currOffset = m;
for(intT i=n-1;i>=0;i--) {
if(tOffsets[i] == INT_T_MAX) tOffsets[i] = currOffset;
else currOffset = tOffsets[i];
}

//fill in offsets of degree 0 vertices by taking closest non-zero
//offset to the right
sequence::scanIBack(tOffsets,tOffsets,n,minF<intT>(),(intT)m);

{parallel_for(uintT i=0;i<n;i++){
uintT o = tOffsets[i];
Expand Down
15 changes: 15 additions & 0 deletions utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ struct identityF { E operator() (const E& x) {return x;}};
template <class E>
struct addF { E operator() (const E& a, const E& b) const {return a+b;}};

template <class E>
struct minF { E operator() (const E& a, const E& b) const {return (a < b) ? a : b;}};

#define _BSIZE 2048
#define _SCAN_LOG_BSIZE 10
#define _SCAN_BSIZE (1 << _SCAN_LOG_BSIZE)
Expand Down Expand Up @@ -167,6 +170,18 @@ namespace sequence {
ET scan(ET *In, ET* Out, intT n, F f, ET zero) {
return scan(Out, (intT) 0, n, f, getA<ET,intT>(In), zero, false, false);}

template <class ET, class intT, class F>
ET scanI(ET *In, ET* Out, intT n, F f, ET zero) {
return scan(Out, (intT) 0, n, f, getA<ET,intT>(In), zero, true, false);}

template <class ET, class intT, class F>
ET scanBack(ET *In, ET* Out, intT n, F f, ET zero) {
return scan(Out, (intT) 0, n, f, getA<ET,intT>(In), zero, false, true);}

template <class ET, class intT, class F>
ET scanIBack(ET *In, ET* Out, intT n, F f, ET zero) {
return scan(Out, (intT) 0, n, f, getA<ET,intT>(In), zero, true, true);}

template <class ET, class intT>
ET plusScan(ET *In, ET* Out, intT n) {
return scan(Out, (intT) 0, n, addF<ET>(), getA<ET,intT>(In),
Expand Down

0 comments on commit 224352e

Please sign in to comment.