Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
.svn
.svn
*.o

# Targets
/libwebgraph.a
/tests/compress_webgraph
/tests/print_webgraph
/tests/print_webgraph_offline
/tests/print_webgraph_sequential
/tests/convert_to_text
/tests/convert_to_binary_edgelist
20 changes: 18 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
SHELL := /bin/bash

include flags.mk

files = asciigraph/offline_graph.o \
Expand All @@ -15,10 +17,20 @@ files = asciigraph/offline_graph.o \
#
# default target
#
all: libs
all: info libs tests

info:
@echo "Compile WebGraph ..."
@echo "Shell: $(SHELL)"
@echo "INCLUDES: $(INCLUDES)"
@echo "LIBS: $(LIBS)"
@echo "FLAGS: $(FLAGS)"

tests: libs
$(MAKE) -C tests
pushd tests && \
$(MAKE) -C . && \
popd



libs:
Expand All @@ -34,6 +46,8 @@ clean:
rm -f core*
rm -f *~
rm -f *.o
rm -f *.a
rm -f *.so
@$(MAKE) -C asciigraph clean
@$(MAKE) -C bitstreams clean
@$(MAKE) -C properties clean
Expand All @@ -42,3 +56,5 @@ clean:
@$(MAKE) -C log clean
@$(MAKE) -C tests clean

.PHONY: all tests libs info clean

39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,42 @@ work.

You will notice a lot of TODOs and commented-out unimplemented
methods. Feel free to write them :)

## Build

Use `BOOST_ROOT` to specify the location of your Boost installation, as below:

```sh
make BOOST_ROOT=/path/to/boost
```

If your boost is installed at default system path, `BOOST_ROOT` can be omit.

Compile success with g++ 11.4.0 and Boost 1.84.0.

To build test programs, use:

```sh
make BOOST_ROOT=/path/to/boost tests
```

## Run

You can use `tests/print_webgraph` to print a webgraph file.

```sh
./tests/print_webgraph /path/to/webgraph/graphname
```

Make sure `graphname.graph`, `graphname.properties` and `graphname.offsets` are in your `path/to/webgraph`. (i.e., the graph path is graph files path without extension.)

To read a graph without offset file (sequential graph), use `test/print_webgraph_sequential`.

To convert graph to binary edge list, run:

```sh
./tests/convert_to_binary_edgelist [input_graph] [output_file]
```

Each edge will represent as 2 64bit integers.

1 change: 0 additions & 1 deletion asciigraph/deps.mk

This file was deleted.

2 changes: 1 addition & 1 deletion asciigraph/offline_vertex_iterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ void offline_vertex_iterator::copy( const offline_vertex_iterator& other ) {
void offline_vertex_iterator::increment() {
string tmp;

bool success = getline( back, tmp );
bool success = (bool)getline( back, tmp );

if( !success ) {
end_marker = true;
Expand Down
38 changes: 19 additions & 19 deletions asciigraph/tests/test_ascii_graph.cpp
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
/*
* Portions copyright (c) 2003-2007, Paolo Boldi and Sebastiano Vigna. Translation copyright (c) 2007, Jacob Ratkiewicz
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/

/*
* Portions copyright (c) 2003-2007, Paolo Boldi and Sebastiano Vigna. Translation copyright (c) 2007, Jacob Ratkiewicz
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#include "../offline_graph.hpp"
#include <iostream>
#include <utility>
Expand Down
1 change: 1 addition & 0 deletions benchmarks/compress_webgraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ int main( int argc, char** argv ) {
quantum = 10000;

bool offline = false, write_offsets = false;
(void) offline; // not used yet

ostringstream help_message_oss;

Expand Down
1 change: 0 additions & 1 deletion bitstreams/deps.mk

This file was deleted.

32 changes: 17 additions & 15 deletions bitstreams/input_bitstream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

#include "../utils/fast.hpp"

#define LOGGING
// #define LOGGING

namespace webgraph {
using namespace std;
Expand Down Expand Up @@ -142,8 +142,10 @@ int ibitstream::read() {
if ( avail == 0 ) {
// then the buffer is empty. attempt to fill it again.
if( is != NULL )
{
assert( buffer->size() == buffer->capacity() );
avail = is->readsome( (char*)&(*buffer).at(0), buffer->size() ); // used to be capacity
}
#ifdef LOGGING
cerr << "==================================================\n";
cerr << "BUFFER REFILLED; first 50 bytes : \n";
Expand Down Expand Up @@ -185,7 +187,7 @@ int ibitstream::read_from_current( unsigned int len ) {
// We just empty everything.
read_bits += len;
fill = 0;
int retval = current & ( 1 << len ) - 1;
int retval = current & (( 1 << len ) - 1);
#ifdef LOGGING
cerr << "\tread_from_current(" << len << ") = " << retval << " "
<< "(current=" << utils::int_to_binary(current,fill) << ")\n";
Expand Down Expand Up @@ -222,11 +224,11 @@ void ibitstream::read( byte bits[], unsigned int len ) {

if ( len <= fill ) {
if ( len <= 8 ) {
bits[ 0 ] = (byte)( read_from_current( len ) << 8 - len );
bits[ 0 ] = (byte)( read_from_current( len ) << (8 - len) );
return;
} else {
bits[ 0 ] = (byte)( read_from_current( 8 ) );
bits[ 1 ] = (byte)( read_from_current( len - 8 ) << 16 - len );
bits[ 1 ] = (byte)( read_from_current( len - 8 ) << (16 - len) );
return;
}
} else {
Expand All @@ -239,26 +241,26 @@ void ibitstream::read( byte bits[], unsigned int len ) {

const unsigned int shift = fill;

bits[ j ] = (byte)( read_from_current( shift ) << 8 - shift );
bits[ j ] = (byte)( read_from_current( shift ) << (8 - shift) );
len -= shift;

i = len >> 3;
while( i-- != 0 ) {
b = read();
// used to be >>>
bits[ j ] |= (( b & 0xFF ) >> shift) & 0xFF; // the last & 0xFF is mine.
bits[ ++j ] = (byte)( b << 8 - shift );
bits[ ++j ] = (byte)( b << (8 - shift) );
}

read_bits += len & ~7;

len &= 7;
if ( len != 0 ) {
if ( len <= 8 - shift ) {
bits[ j ] |= (byte)( read_from_current( len ) << 8 - shift - len );
bits[ j ] |= (byte)( read_from_current( len ) << (8 - shift - len) );
} else {
bits[ j ] |= (byte)( read_from_current( 8 - shift ) );
bits[ j + 1 ] = (byte)( read_from_current( len + shift - 8 ) << 16 - shift - len );
bits[ j + 1 ] = (byte)( read_from_current( len + shift - 8 ) << (16 - shift - len) );
}
}
}
Expand Down Expand Up @@ -383,7 +385,7 @@ void ibitstream::set_position( unsigned long position ) {

int pos = (int)this->pos;

if ( delta <= avail && delta >= - pos ) {
if ( delta <= (int)avail && delta >= - pos ) {
// We can reposition just by moving into the buffer.
avail -= delta;
pos += delta;
Expand All @@ -409,7 +411,7 @@ int ibitstream::read_unary() {
if ( fill < 8 )
refill();

#if 1
#ifdef LOGGING
cerr << "current: " << current << endl
<< "fill: " << fill << endl;
#endif
Expand All @@ -425,7 +427,7 @@ int ibitstream::read_unary() {

read_bits += x + 1;
fill -= x + 1;
#if 1
#ifdef LOGGING
cerr << "1. read_unary() = " << x << endl;
#endif
return x;
Expand All @@ -437,7 +439,7 @@ int ibitstream::read_unary() {
x += 7 - ( fill = BYTEMSB[ current ] );
read_bits += x + 1;

#if 1
#ifdef LOGGING
cerr << "2. read_unary() = " << x << endl;
#endif
return x;
Expand Down Expand Up @@ -765,7 +767,7 @@ int ibitstream::read_zeta( int k ) {
if ( pre_comp != 0 ) {
read_bits += pre_comp >> 8;
fill -= pre_comp >> 8;
#if 1
#ifdef LOGGING
cerr << "\t1. read_zeta returning " << (pre_comp & 0xFF) << endl;
#endif
return pre_comp & 0xFF;
Expand All @@ -778,15 +780,15 @@ int ibitstream::read_zeta( int k ) {
const int m = read_int( h * k + k - 1 );
if ( m < left ) {
int retval = m + left - 1;
#if 1
#ifdef LOGGING
cerr << "\t2. read_zeta returning " << retval << endl;
#endif
return retval;
}

int retval = ( m << 1 ) + read_bit() - 1;

#if 1
#ifdef LOGGING
cerr << "\t3. read_zeta returning " << retval << endl;
#endif

Expand Down
2 changes: 1 addition & 1 deletion bitstreams/input_bitstream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ class ibitstream {
<< utils::int_to_binary( current, fill )
<< "\n";
#endif
} catch( eof_exception e ) {
} catch( eof_exception& e ) {
// don't care.
}
}
Expand Down
10 changes: 5 additions & 5 deletions bitstreams/output_bitstream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ int obitstream::write_byte_offset( const byte bits[],
if ( len <= free ) {
/// used to be >>>
// this is okay because bits[] is unsigned, so 0's will be shifted in
return write_in_current( bits[ offset ] >> 8 - len, len );
return write_in_current( bits[ offset ] >> (8 - len), len );
}
else {
const int shift = free;
Expand All @@ -193,15 +193,15 @@ int obitstream::write_byte_offset( const byte bits[],
// cerr << "shift = " << shift << endl;

// used to be >>>
write_in_current( bits[ offset ] >> 8 - shift, shift );
write_in_current( bits[ offset ] >> (8 - shift), shift );

len -= shift;

j = offset;
i = len >> 3;
while( i-- != 0 ) {
// used to be >>>
write( bits[ j ] << shift | ( bits[ j + 1 ] & 0xFF ) >> 8 - shift );
write( bits[ j ] << shift | ( bits[ j + 1 ] & 0xFF ) >> (8 - shift) );
written_bits += 8;
j++;
}
Expand All @@ -210,12 +210,12 @@ int obitstream::write_byte_offset( const byte bits[],
if ( q != 0 ) {
if ( q <= 8 - shift ) {
/// used to be >>>
write_in_current( bits[ j ] >> 8 - shift - q, q );
write_in_current( bits[ j ] >> (8 - shift - q), q );
}
else {
write_in_current( bits[ j ], 8 - shift );
/// used to be >>>
write_in_current( bits[ j + 1 ] >> 16 - q - shift, q + shift - 8 );
write_in_current( bits[ j + 1 ] >> (16 - q - shift), q + shift - 8 );
}
}

Expand Down
2 changes: 1 addition & 1 deletion bitstreams/output_bitstream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <fstream>
#include <cassert>

#include <boost/shared_ptr.hpp>
#include <boost/smart_ptr/shared_ptr.hpp>

#include "../log/logger.hpp"

Expand Down
2 changes: 1 addition & 1 deletion bitstreams/tests/reader_writer_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ int main(int, char**) {

cerr << "Done with files.. now time for arrays.\n";

shared_ptr< vector<unsigned char> > res = test_write_to_array( b, sizeof(somebits) );
boost::shared_ptr< vector<unsigned char> > res = test_write_to_array( b, sizeof(somebits) );

cerr << "We've written .. now let's see how it looks.\n";
cerr << "The bytes of res[] are " << endl;
Expand Down
Loading