示例#1
0
for seedi in range(number_of_seeds):
    seede= 363+ seedi*140
    random.seed(seede)
    print( "######################### next seed , the seed is ", seede , "#################")


    for a1 in range(xLengthGraph):
        Clean(winnerVotes)

        num_of_Friends = 300+(50*a1) #300-800 friends
        barabasiGraph = barabasi_albert_graph(num_of_Friends, num_of_Arcs, seed=seede)
        #  מתחיל לייצר קשתות רק כאשר יש לו אמ קודקודים ברשת
        # (n-m)m = edge

        edges = nx.edges(barabasiGraph)
        # print(edges)
        friends = [set() for j in range(len(barabasiGraph))]
        # [(0, 2), (0, 3), (0, 1), (1, 2), (1, 3), (1, 4), (2, 3), (2, 4)]

        Opinions = creatOpinions(barabasiGraph, typeOfVotes, Opinions2, winnerVotes)
        # print(np.matrix(Opinions))

        winnerStart = getWinner(winnerVotes, typeOfVotes)

        votes = [[0 for i in range(len(typeOfVotes))] for j in range(len(friends))]
        votes2 = [[0 for i in range(len(typeOfVotes))] for j in range(len(friends))]
        start_change_winner_graph = copy.deepcopy(winnerStart)
        start_winner_graph = copy.deepcopy(winnerVotes)
        Opinions = copy.deepcopy(Opinions2)
示例#2
0
winner_change_graph_avg = [0 for j in range(xLengthGraph)]

for seedi in range(number_of_seeds):
    seede = 363 + seedi * 140
    random.seed(seede)
    print("######################### next seed , the seed is ", seede, "#################")

    for a1 in range(xLengthGraph):
        Clean(winnerVotes)

        num_of_friends = 50 + (25 * a1)
        GNP = nx.gnp_random_graph(num_of_friends, seede, directed=False)
        #  מתחיל לייצר קשתות רק כאשר יש לו אמ קודקודים ברשת
        # (n-m)m = edge

        edges = nx.edges(GNP)
        # print(edges)
        friends = [set() for j in range(len(GNP))]
        # [(0, 2), (0, 3), (0, 1), (1, 2), (1, 3), (1, 4), (2, 3), (2, 4)]

        Opinions = creatOpinions(GNP, typeOfVotes, Opinions2, winnerVotes)
        # print(np.matrix(Opinions))

        winnerStart = getWinner(winnerVotes, typeOfVotes)

        votes = [[0 for i in range(len(typeOfVotes))] for j in range(len(friends))]
        votes2 = [[0 for i in range(len(typeOfVotes))] for j in range(len(friends))]
        start_change_winner_graph = copy.deepcopy(winnerStart)
        start_winner_graph = copy.deepcopy(winnerVotes)
        prints(typeOfVotes, winnerVotes, winnerStart, Opinions2, edges)