def random_graph_compare_LTM_analyse(n=100, p_edge=0.1, alpha=0.5, mc_greedy=100, k=5, is_random_weights=True): G = nx.erdos_renyi_graph(n, p_edge, directed=True) if is_random_weights: w_matrix = weight_matrix(G, alpha) else: w_matrix = degree_matrix(G, alpha) LTM = Live_Blocked_Model(G, w_matrix, from_model="LTM") random_a0 = random_active_set(LTM, k) degree_a0 = highest_degree_active_set(LTM, k) greedy_a0 = greedy_active_set(LTM, k, mc=mc_greedy) sets = [random_a0, degree_a0, greedy_a0] influences = list(map(lambda x: LTM.run_model(x, mc=1000), sets)) print(sets) print(influences) return sets, G, w_matrix
def config_compare_ICM(n=100, degree_dist=[], alpha=0.5, mc_greedy=100, k=5): G = nx.configuration_model(degree_dist) p_matrix = np.random.uniform(low=0, high=alpha, size=(n, n)) ICM = Independent_Cascade_Model(G, p_matrix) random_a0 = random_active_set(ICM, k) degree_a0 = highest_degree_active_set(ICM, k) greedy_a0 = greedy_active_set(ICM, k, mc=mc_greedy) sets = [random_a0, degree_a0, greedy_a0] influences = map(lambda x: ICM.run_model(x, mc=1000), sets) return list(influences)
def compare_new_algorithms(n=100, p_edge=0.1, alpha=0.0, mc_greedy=1000, k=5): G = nx.erdos_renyi_graph(n, p_edge, directed=True) w_matrix = weight_matrix(G, alpha) LTM = Live_Blocked_Model(G, w_matrix, from_model="LTM") random_a0 = random_active_set(LTM, k) degree_a0 = highest_degree_active_set(LTM, k) greedy_a0 = greedy_active_set(LTM, k, mc=mc_greedy) avg_weight_a0 = highest_avg_weight_active_set(LTM, k) tot_weight_a0 = highest_total_weight_active_set(LTM, k) sets = [random_a0, degree_a0, greedy_a0, avg_weight_a0, tot_weight_a0] influences = map(lambda x: LTM.run_model(x, mc=1000), sets) return list(influences)
def random_graph_compare_ICM_analyse(n=100, p_edge=0.1, alpha=0.5, mc_greedy=100, k=5, is_random_weights=True): G = nx.erdos_renyi_graph(n, p_edge, directed=True) if is_random_weights: p_matrix = np.random.uniform(low=0, high=alpha, size=(n, n)) else: p_matrix = degree_matrix(G, alpha) ICM = Independent_Cascade_Model(G, p_matrix) random_a0 = random_active_set(ICM, k) degree_a0 = highest_degree_active_set(ICM, k) greedy_a0 = greedy_active_set(ICM, k, mc=mc_greedy) sets = [random_a0, degree_a0, greedy_a0] influences = list(map(lambda x: ICM.run_model(x, mc=1000), sets)) print(sets) print(influences) return sets, G , p_matrix