Skip to content
Permalink
Browse files

improved documentation and made right-sorted an optional positional a…

…rgument
  • Loading branch information...
athalhammer committed Jul 17, 2019
1 parent 1e48c65 commit c97b8f3bde65fdf2e069e5189136c01927baaef7
Showing with 15 additions and 10 deletions.
  1. +2 −2 README.md
  2. +1 −1 danker.sh
  3. +12 −7 danker/danker.py
@@ -114,7 +114,7 @@ H 0.15000000000000002
I 0.15000000000000002
K 0.15000000000000002
L 0.15000000000000002
$ ./danker/danker.py ./test/graphs/test.links 0.85 40 1 --right_sorted ./test/graphs/test.links.right
$ ./danker/danker.py ./test/graphs/test.links ./test/graphs/test.links.right 0.85 40 1
1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.28.29.30.31.32.33.34.35.36.37.38.39.40.
Computation of PageRank on './test/graphs/test.links' with danker took 0.01 seconds.
A 0.30410528185693986
@@ -172,7 +172,7 @@ This software is licensed under GPLv3. (see https://www.gnu.org/licenses/).

5. __Can I use danker to compute PageRank on other graphs than Wikipedia?__

_Sure, you can use the file `./danker/danker.py` for computing PageRank on your graph. If you pass a "right sorted" file with the optional parameter `--right_sorted` automatically the slower method with low memory footprint will be used. The memory-intensive method will be used otherwise. You can sort tab-separated files with the Unix command `sort --key=2 -o output-file input-file`._
_Sure, you can use the file `./danker/danker.py` for computing PageRank on your graph. If you pass a "right sorted" file with the optional parameter `right_sorted` automatically the slower method with low memory footprint will be used. The memory-intensive method will be used otherwise. You can sort tab-separated files with the Unix command `sort --key=2 -o output-file input-file`. Type `./danker/danker.py -h` for options. In addition, you can use danker as a library in your Python 3.x code (cf.: https://danker.rtfd.org)_

6. __Why do the scores not form a nice probability distribution?__

@@ -53,7 +53,7 @@ if [ "$2" == "BIGMEM" ]; then
> "$filename".rank
else
sort -S 50% --field-separator=$'\t' --key=2 --temporary-directory=. -no "$filename"".right" "$filename"
./danker/danker.py "$filename" --right_sorted "$filename"".right" $DAMPING_FACTOR $ITERATIONS $START_VALUE \
./danker/danker.py "$filename" "$filename"".right" $DAMPING_FACTOR $ITERATIONS $START_VALUE \
| sed "s/\(.*\)/Q\1/" \
> "$filename".rank
rm "$filename"".right"
@@ -126,7 +126,7 @@ def init(left_sorted, start_value, smallmem):
:func:`danker_smallmem` (file iteration) or
:func:`danker_bigmem` (in-memory). Default is "False".
:returns: Dictionary with each key referencing a node. The value is a
list with the following contentsi - depending on the smallmem
list with the following contents - depending on the smallmem
parameter and the intended use:
* :func:`danker_bigmem` [link_count:int, start_value:float,
@@ -262,14 +262,19 @@ def _main():
"""
Execute main program.
"""
parser = argparse.ArgumentParser(description='danker PageRank.')
parser.add_argument('left_sorted')
parser.add_argument('--right_sorted')
parser.add_argument('damping', type=float)
parser.add_argument('iterations', type=int)
parser.add_argument('start_value', type=float)
parser = argparse.ArgumentParser(description='danker PageRank. Compute ' +
'PageRank on large graphs on low-cost hardware.')
parser.add_argument('left_sorted', type=str, help='A two-column, ' +
'tab-separated file sorted by the left column.')
parser.add_argument('right_sorted', nargs='?', type=str, help='The same ' +
'file as left_sorted but sorted by the right column.')
parser.add_argument('damping', type=float, help='PageRank damping factor.')
parser.add_argument('iterations', type=int, help='Number of PageRank ' +
'iterations.')
parser.add_argument('start_value', type=float, help='PageRank starting value.')
args = parser.parse_args()
start = time.time()

dictionary = init(args.left_sorted, args.start_value, args.right_sorted)
result_position = (args.iterations % 2) + 1
if args.right_sorted:

0 comments on commit c97b8f3

Please sign in to comment.
You can’t perform that action at this time.