Ejemplo n.º 1
0
def max_feat(G, L, S, features, R, F, IC):
    best_feat_spread = 0
    for feat in F:
        if IC:
            spread = run_ic(G, L, S, features + [feat], R)
        else:
            spread = run_lt(G, L, S, features + [feat], R)
        if spread > best_feat_spread:
            best_feat = feat
            best_feat_spread = spread
    assert best_feat
    return best_feat
Ejemplo n.º 2
0
Archivo: main.py Proyecto: nd7141/PIMUS
if __name__ == "__main__":

    G = read_graph("datasets/Wiki-Vote_graph_ic.txt", True)
    L = read_likes("datasets/Wiki-Vote_likes.txt")
    K = 30
    R = 100

    #comparison of PIMUS to IM
    # S = random.sample(G, 50)
    # f = greedy(G, L, S, K, R, False)
    # print 'PIMUS spread:', run_lt(G, L, S, f, R)

    # S = comparison.greedy_im(G, 5, R)
    # print 'IM spread:', comparison.run_ic(G, S, R)

    # comparison of different PIMUS algorithms
    l = 20
    count = 0
    spread = 0
    for _ in range(l):
        S = random.sample(G.nodes(), 50)
        f1 = greedy(G, L, S, K, R)
        print sorted(f1)

        spread += run_ic(G, L, S, f1, R)
    print 'Average spread:', spread/l
    with open('data/spread{0}.txt'.format(K), 'w+') as f:
        f.write("{0}".format(spread/l))

    console = []