Beispiel #1
0
def simulate():

    N = 100
    R = 5
    b1 = 1.5
    b0 = 0.5
    a = 1.0
    alpha0 = a * np.ones(R)
    SBM_1 = StochasticBlockModel(R, b0, b1, alpha0)
    (A, f, theta) = sample_network(SBM_1, N)
    (B, pi) = theta

    p = 0.3
    q = 0.7
    N = 100
    R = 5

    ####run once on mac for picked SBM data
    ####start-----------pickle string won't keep the graph
    graph_1 = Gen_SBM(p, q, N, R)
    print graph_1
    Graph.write_pickle(graph_1, "SBM_03_07_1000_5.p")
    ####end-------------

    SBM_1 = Graph.Read_Pickle("SBM_03_07_1000_5.p")
    SBM_2 = sparsify.spars_combi(SBM_1, epsilon=0.5)
Beispiel #2
0
 def sim(eps, GraphName):
     SBM_expanded = Graph.Read_Ncol(GraphName + "_expanded.txt", directed=False)
     w_sum1 = sum(SBM_expanded.es["weight"])
     print w_sum1
     e_num1 = SBM_expanded.ecount()
     SBM_2 = sparsify.spars_combi(SBM_expanded, epsilon=eps)
     # through away weights for 3-hop recalculation, write into a temparary file
     SBM_2.write_ncol(GraphName + "_sparse_list.txt", weights=None)
     Expand(GraphName + "_sparse")
     SBM_recalc = Graph.Read_Ncol(GraphName + "_sparse_expanded.txt", directed=False)
     w_sum2 = sum(SBM_recalc.es["weight"])
     # need to modify! calculate real weight instead
     print w_sum2
     e_num2 = SBM_2.ecount()
     return (w_sum1 - w_sum2), (e_num1 - e_num2)