def multi_abp(G, r, lambda1, m, mp, dim, K):
    N = len(G.nodes())
    mt = np.zeros((N, dim))
    for k in range(dim):
        y_abp = SBM.SBM_ABP(G, r, lambda1, m, mp)
        mt[:, k] = y_abp
    k_means = KMeans(n_clusters=K, max_iter=100, precompute_distances=False)
    k_means.fit(mt)
    y = k_means.labels_
    return y
 nmi_arry = {}
 ccr_arry = {}
 ars_arry = {}
 # parameter setting
 #    c_array = [0.2, 0.4, 0.5, 0.6, 0.8, 1.0, 1.5, 2.0]  # alpha = clog(n)/n
 #    c_array = [0.4, 0.6, 0.8, 1.0, 1.5, 2.0, 4.0]  # alpha = clog(n)/n
 c_array = [0.6, 0.8, 1.0, 1.2, 1.3, 1.5, 2.0, 2.5, 3.0,
            4.0]  # alpha = clog(n)/n
 K_array = [5]  # number of communities
 N_array = [1000]  # number of nodes
 lambda_array = [0.9]  # B0 = lambda*I + (1-lambda)*ones(1,1)
 # scanning through parameters
 for c, K, N, lambda_n in itertools.product(c_array, K_array, N_array,
                                            lambda_array):
     print 'K:', K, 'N:', N, 'c:', c, 'lambda:', lambda_n
     model_sbm1 = SBM.SBM_param_init1(K, N, lambda_n, c)
     for rand in range(rand_tests):
         strsub1 = 'K' + str(K) + 'N' + str(N) + 'c' + str(c) + 'la' + str(
             lambda_n) + 'rd' + str(rand)  # for saving results
         # simulate graph
         G = SBM.SBM_simulate_fast(model_sbm1)
         ln, nodeslist = get_label_list(G)
         # algo1: proposed deepwalk algorithm
         model_w2v = SBM.SBM_learn_deepwalk_1(G, num_paths, length_path,
                                              emb_dim, rw_filename,
                                              emb_filename, winsize)
         X = model_w2v[nodeslist]
         k_means = KMeans(n_clusters=K,
                          max_iter=100,
                          precompute_distances=False)
         k_means.fit(X)
 # generating multiple graphs for the same parameter setting
 rand_tests = 5
 # setting storage space for results
 nmi_arry = {}
 ccr_arry = {}
 ars_arry = {}
 # parameter setting
 c_array = [2]  # alpha = clog(n)/n
 K_array = [5]  # number of communities
 N_array = [10000]  # number of nodes
 lambda_array = [0.9]  # B0 = lambda*I + (1-lambda)*ones(1,1)
 # scanning through parameters
 for c, K, N, lambda_n in itertools.product(c_array, K_array, N_array,
                                            lambda_array):
     print 'K:', K, 'N:', N, 'c:', c, 'lambda:', lambda_n
     model_sbm1 = SBM.SBM_param_init1(K, N, lambda_n, c)
     for rand in range(rand_tests):
         strsub1 = 'K' + str(K) + 'N' + str(N) + 'c' + str(c) + 'la' + str(
             lambda_n) + 'rd' + str(rand)  # for saving results
         # simulate graph
         G = SBM.SBM_simulate_fast(model_sbm1)
         ln, nodeslist = get_label_list(G)
         # algo1: proposed deepwalk algorithm
         # scanning parameter settings
         emb_dimensions = [50]
         winsize_arry = [8]
         num_path_arry = [5, 10, 15, 20, 25, 30]
         length_path_arry = [60]
         for length_path, num_paths in itertools.product(
                 length_path_arry, num_path_arry):
             # creating random walks and save in memory