Readme for /undirected/unweighted
===========================
The code is an implementation of the hop-doubling algorithm for unweighted undirected graphs in the following VLDB 2014 paper:
Hop Doubling Label Indexing for Point-to-Point Distance Querying on Scale-Free Networks. 
We incorporate a bit-parallel component after generating 2-hop index to speed up memory-based querying in unweighted undirected graphs. More details about bit-parallel can be found in the following SIGMOD 2013 paper:
Fast exact shortest-path distance queries on large networks by pruned landmark labeling.

Usage:

(1) Machine:
The code is tested in Ubuntu Linux envionment with g++ complier. The default setting is to use 4GB memory, but you can also change it in the file "ioU.h". For example, setting the memory usage to 1GB can be done by changing the following line in "inU.h" from
const long long memSize = 4LL * 1024 * 1024 * 1024 ;
to
const long long memSize = 1LL * 1024 * 1024 * 1024 ;

(2) Input file format:
Our input file is in text format. For a directed graph G=(V,E), there are |E|+1 lines in the input file. The first line is a number |V|. In the following |E| lines, each line contain 3 numbers, i.e. u v d, corresponding to an edge from vertex u to v with length d. We consider each undirected edge in the input file as two directed edges, so if there is an edge "u v d", there must be another line "v u d" for the reverse direction, which also means |E| is 2 times of the number of undirected edges in the graph. We assume each vertex is an integer in [0, |V|-1], and each length is a small integer. One example is the file "exampleU.txt".

(3) Indexing: 
g++ ioU.h labelU.cpp -O3 && ./a.out inputFileName
For example, to index the file "exampleU.txt", we should use
g++ ioU.h labelU.cpp -O3 && ./a.out exampleU.txt

Some inforamtion about the indexing process can be found in the screen, e.g. indexing time, index size, # of iterations. One example is as followed,
"
exampleU.txt
iteration 1 begin
iteration 2 begin
iteration 3 begin
iteration 4 begin
iteration 5 begin
iteration 6 begin
iteration 7 begin
iteration 8 begin
index begin
indexSize 8.942955 MB
tRun 2.258780 (sec)
"
After indexing, 2 files are generated as 2-hop index for querying, i.e. inputFileName.out, inputFileName.deg.

(4) Transforming to bit-parallel format:
g++ ioBP.h toBP.cpp -O3 && ./a.out inputFileName
For example, to transform the 2-hop index of "exampleU.txt" to bit-parallel format, we should use
g++ ioBP.h toBP.cpp -O3 && ./a.out exampleU.txt

Some inforamtion about the transforming process can be found in the screen, e.g. transforming time, index size. One example is as followed,
"
36692 vertices
indexSize 10.012700 (MB)
to bit parallel time: 0.739169 (sec)
"
After transforming, 4 files are generated as 2-hop index with bit-parallel format for querying, i.e. inputFileName.bpout, inputFileName.bpdeg, inputFileName.bps, inputFileName.bpsr. Meanwhile, the 2-hop index files are deleted.

(5) Internal(memory-based) querying:
g++ ioBP.h queryUIBP.cpp -O3 && ./a.out inputFileName
For example, to query the file "exampleU.txt", we should use
g++ ioBP.h queryUIBP.cpp -O3 && ./a.out exampleU.txt

Some inforamtion about the querying process can be found in the screen, e.g. index loading time, average query time. One example is as followed,
"
36692
load time 27.147000 (ms)
average query time 0.084000 (mirco second)
"

