def main():
    start_time = time.time()

    args = utils.create_argument_parser()
    graph = utils.load_graph(args.dataset, args.w)
    graph_copy = deepcopy(graph)

    communities = community_search(graph)
    com_dict = {}

    for i in range(len(communities)):
        com_dict[i] = communities[i]

    utils.print_comm_info_to_display(com_dict)
    print('modularity_value =', modularity(graph, com_dict))

    com_dict2 = {}
    for k, v in com_dict.items():
        for node in v:
            com_dict2[node] = k

    print('NMI =', NMI(args.output, com_dict2))

    finish_time = time.time()
    print('\nDone in %.4f seconds.' % (finish_time - start_time))
예제 #2
0
def main():
    start_time = time.time()

    args = utils.create_argument_parser()
    graph = utils.load_graph(args.dataset, args.w)
    graph_copy = deepcopy(graph)

    preprocess(graph)
    c = greedy_modularity_communities(graph)

    finish_time = time.time()
    print('\nDone in %.4f seconds.' % (finish_time - start_time))

    communities = dict()
    for i in range(len(c)):
        communities[i] = list(c[i])

    partition = create_partition(communities)
    utils.print_comm_info_to_display(communities)
    # utils.write_comm_info_to_file(partition)

    print('modularity_value =', modularity(graph_copy, communities))
    print('NMI =', NMI(args.output, partition))

    finish_time = time.time()
    print('\nDone in %.4f seconds.' % (finish_time - start_time))
예제 #3
0
def _main():
    start_time = time.time()

    args = utils.create_argument_parser()
    graph = utils.load_graph(args.dataset, False)
    graph_copy = deepcopy(graph)

    communities = community_detect(graph)
    number_of_nodes = 0
    com_dict = {}

    for i in range(len(communities)):
        com_dict[i] = communities[i]
        number_of_nodes += len(communities[i])

    print(number_of_nodes, ' nodes has been analyzed.')

    utils.print_comm_info_to_display(com_dict)
    print('modularity_value =', modularity(graph_copy, com_dict))

    com_dict2 = {}
    for k, v in com_dict.items():
        for node in v:
            com_dict2[node] = k

    print('NMI =', NMI(args.output, com_dict2))

    finish_time = time.time()
    print('\nDone in %.4f seconds.' % (finish_time - start_time))
예제 #4
0
def main():
    start_time = time.time()

    args = utils.create_argument_parser()
    graph = utils.load_graph(args.dataset, args.w)
    partition = best_partition(graph)

    finish_time = time.time()
    print('\nDone in %.4f seconds.' % (finish_time - start_time))

    communities = utils.extract_communities(partition)
    utils.print_comm_info_to_display(communities)
    # utils.write_comm_info_to_file(args.output, partition)

    print('modularity_value =', modularity(graph, communities))
    print('NMI =', NMI(args.output, partition))

    finish_time = time.time()
    print('\nDone in %.4f seconds.' % (finish_time - start_time))
def main():
    start_time = time.time()

    args = utils.create_argument_parser()
    graph = utils.load_graph(args.dataset, args.w)
    graph_copy = deepcopy(graph)

    communities = community_detection(graph)
    com_dict = {}

    for i in range(len(communities)):
        com_dict[i] = communities[i]

    utils.print_comm_info_to_display(com_dict)
    # output_name = args.dataset[args.dataset.rindex('/'):]
    # utils.write_comm_info_to_file(output_name, com_dict)

    print('modularity_value =', modularity(graph_copy, com_dict))
    print('NMI =', NMI(args.output, com_dict))

    finish_time = time.time()
    print('\nDone in %.4f seconds.' % (finish_time - start_time))