def pagerank(graph, damping_factor=<NUM_LIT>, max_iterations=<NUM_LIT:100>, min_delta=<NUM_LIT>):
nodes = graph.nodes()<EOL>graph_size = len(nodes)<EOL>if graph_size == <NUM_LIT:0>:<EOL><INDENT>return {}<EOL><DEDENT>min_value = (<NUM_LIT:1.0>-damping_factor)/graph_size <EOL>pagerank = dict.fromkeys(nodes, <NUM_LIT:1.0>/graph_size)<EOL>for i in range(max_iterations):<EOL><INDENT>diff = <NUM_LIT:0> <EOL>for node in nodes:<EOL><INDENT>rank = min_value<EOL>for referring_page in graph.incidents(node):<EOL><INDENT>rank += damping_factor * pagerank[referring_page] / len(graph.neighbors(referring_page))<EOL><DEDENT>diff += abs(pagerank[node] - rank)<EOL>pagerank[node] = rank<EOL><DEDENT>if diff < min_delta:<EOL><INDENT>break<EOL><DEDENT><DEDENT>return pagerank<EOL>
Compute and return the PageRank in an directed graph.    

@type  graph: digraph
@param graph: Digraph.

@type  damping_factor: number
@param damping_factor: PageRank dumping factor.

@type  max_iterations: number 
@param max_iterations: Maximum number of iterations.

@type  min_delta: number
@param min_delta: Smallest variation required to have a new iteration.

@rtype:  Dict
@return: Dict containing all the nodes PageRank.