def test(graph_file, d, iterations):
    """This is the Python implementation of PageRank."""
    in_links = {}
    out_degree = {}
    pagerank = {}
    file = open(graph_file)
    for line in file:
        (source, dest) = line.rstrip().split()
        try:
            in_links[dest].add(source)
        except KeyError:
            in_links[dest] = set(source)
        try:
            out_degree[source] += 1
        except KeyError:
            out_degree[source] = 1
        pagerank[source] = 1.0
        pagerank[dest] = 1.0
    file.close()
    old_pr = pagerank
    new_pr = {}
    for iteration in xrange(0, iterations):
        for node in old_pr:
            new_pr[node] = (1 - d)
            try:
                new_pr[node] += \
                d * sum([old_pr[n] / out_degree[n] for n in in_links[node]])
            except KeyError:
                pass
        tmp = old_pr
        old_pr = new_pr
        new_pr = tmp
    return old_pr
dataset/ETHPy150Open twitter/pycascading/examples/pagerank.py/test/original