Example #1
0
                         help='Damping factor (float)',
                         default=0.15,
                         type='float')
    optparser.add_option('--decay_factor',
                         dest='decay_factor',
                         help='Decay factor (float)',
                         default=0.9,
                         type='float')
    optparser.add_option('--iteration',
                         dest='iteration',
                         help='Iteration (int)',
                         default=500,
                         type='int')

    (options, args) = optparser.parse_args()

    file_path = options.input_file
    iteration = options.iteration
    damping_factor = options.damping_factor
    decay_factor = options.decay_factor

    result_dir = 'result'
    fname = file_path.split('/')[-1].split('.')[0]

    graph = init_graph(file_path)
    sim = Similarity(graph, decay_factor)

    output_HITS(iteration, graph, result_dir, fname)
    output_PageRank(iteration, graph, damping_factor, result_dir, fname)
    output_SimRank(iteration, graph, decay_factor, result_dir, fname)
Example #2
0
from src.utils.utils import init_graph


def PageRank_one_iter(graph, d):
    node_list = graph.nodes
    for node in node_list:
        node.update_pagerank(d, len(graph.nodes))
    graph.normalize_pagerank()
    # print(graph.get_pagerank_list())
    # print()


def PageRank(graph, d, iteration=100):
    for i in range(iteration):
        PageRank_one_iter(graph, d)


if __name__ == '__main__':

    iteration = 100
    damping_factor = 0.15

    graph = init_graph('./dataset/graph_4.txt')

    PageRank(iteration, graph, damping_factor)
    print(graph.get_pagerank_list())
Example #3
0
    for i in range(edge_num):
        edge = random.choice(edge_pool)
        edges.append(edge)

    with open('dataset/node.txt', 'w') as f:
        for edge in edges:
            f.write(f'{edge[0]},{edge[1]}\n')


# create_graph(10)

time_list = []

for i in range(0, 100, 10):
    print(i)
    create_graph(i)
    graph = init_graph('dataset/node.txt')
    sim = Similarity(graph, 0.9)

    prev_time = time.time()
    SimRank(graph, sim)
    time_list.append(time.time() - prev_time)

x = [2*i for i in range(0, 100, 10)]

plt.plot(x, time_list)
plt.title('SimRank computation time with different number of edges')
plt.xlabel('Edges')
plt.ylabel('Time (sec)')
plt.show()