Readme for /undirected
===========================
The code is an implementation of the hop-doubling algorithm for undirected graphs in the following VLDB 2014 paper:
Hop Doubling Label Indexing for Point-to-Point Distance Querying on Scale-Free Networks. 

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 follows.
"
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) External(disk-based) querying:
g++ ioU.h queryUE.cpp -O3 && ./a.out inputFileName
For example, to query the file "exampleU.txt", we should use
g++ ioU.h queryUE.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 follows.
"
load time 0.235000 (ms)
36692 vertices
average query time 0.265915 (ms)
"
Please remember to clear cache before running disk-based querying. One possible way is as follows.
sh -c "sync; echo 3 > /proc/sys/vm/drop_caches"

(5) Internal(memory-based) querying:
g++ ioU.h queryUI.cpp -O3 && ./a.out inputFileName
For example, to query the file "exampleU.txt", we should use
g++ ioU.h queryUI.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 follows.
"
36692 vertices
load time 14.678000 (ms)
average time 0.378000 (mirco second)
"


