-
Notifications
You must be signed in to change notification settings - Fork 1
/
simple_4_vertices.py
43 lines (32 loc) · 1.3 KB
/
simple_4_vertices.py
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
41
42
43
import argparse
import logging
from page_rank.examples.utils import setup_cli_and_run
RUN_TIME = 2.1
def run(show_in=False, show_out=False):
from page_rank.model.tools.simulation import PageRankSimulation
############################################################################
# Construct simulation graph
# From: https://www.youtube.com/watch?v=P8Kt6Abq_rM
edges = [
('A', 'B'),
('A', 'C'),
('B', 'D'),
('C', 'A'),
('C', 'B'),
('C', 'D'),
('D', 'C'),
]
############################################################################
# Run simulation / report
with PageRankSimulation(RUN_TIME, edges, damping=1 - 10e-10,
log_level=logging.INFO) as sim:
sim.draw_input_graph(show_graph=show_in, save_graph=True)
sim.run(verify=True)
sim.draw_output_graph(show_graph=show_out, save_graph=True)
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Simple Page Rank w/ 4 nodes.')
parser.add_argument('--show-in', action='store_true',
help='Display directed graph input.')
parser.add_argument('--show-out', action='store_true',
help='Display ranks curves output.')
setup_cli_and_run(parser, run)