コード例 #1
0
def multi_sampling():
    f = FaceData()
    G = f.create_graph()  # 获取原始数据

    _degree = dict()  # 分析重组数据
    chushu = 0
    for i in xrange(38):
        BFS = common.BFS(G, 10000)
        for i in BFS:
            _degree[G.degree(i)] = _degree.get(G.degree(i), 0) + 1
        chushu += len(BFS)
        print "step ", i

    # 处理数据,取平均的度分布
    x = sorted(_degree.iterkeys())  #生成x轴序列,从1到最大度
    num = chushu
    y = []
    for i in x:
        y.append(float(_degree[i]) / num)

    # 保存数据
    f = open("../compare/degree_plot/Epin_BFS.txt", "w")
    try:
        for i in x:
            f.write(str(i) + " " + str(float(_degree[i]) / num) + "\n")
    finally:
        f.close()
コード例 #2
0
def multi_sampling():
    f = FaceData()
    G = f.create_graph()  # 获取原始数据

    _degree = dict()  # 分析重组数据
    chushu = 0
    for i in xrange(38):
        mhrw = common.metropolis_hastings_random_walk(G, None, 10000, "unique")
        # impore = improve_MH.impore_02(G, None, 10000, "unique")
        for i in mhrw:
            _degree[G.degree(i)] = _degree.get(G.degree(i), 0) + 1
        chushu += len(mhrw)
        print "step "

    # 处理数据,取平均的度分布
    x = sorted(_degree.iterkeys())  #生成x轴序列,从1到最大度
    num = chushu
    y = []
    for i in x:
        y.append(float(_degree[i]) / num)

    # 保存数据
    f = open("../compare/degree_plot/dup_Twitter_Mh.txt", "w")
    try:
        for i in x:
            f.write(str(i) + " " + str(float(_degree[i]) / num) + "\n")
    finally:
        f.close()

    ##################
    _degree = dict()  # 分析重组数据
    chushu = 0
    for i in xrange(38):
        # mhrw = common.metropolis_hastings_random_walk(G,None,10000,"unique")
        impore = improve_MH.impore_02(G, None, 10000, "unique")
        for i in impore:
            _degree[G.degree(i)] = _degree.get(G.degree(i), 0) + 1
        chushu += len(impore)
        print "step "

    # 处理数据,取平均的度分布
    x = sorted(_degree.iterkeys())  #生成x轴序列,从1到最大度
    num = chushu
    y = []
    for i in x:
        y.append(float(_degree[i]) / num)

    # 保存数据
    f = open("../compare/degree_plot/dup_Twitter_Ud.txt", "w")
    try:
        for i in x:
            f.write(str(i) + " " + str(float(_degree[i]) / num) + "\n")
    finally:
        f.close()
コード例 #3
0
def compare_press():
    f = FaceData()
    G = f.create_graph()  # 获取原始数据

    rw = common.random_walk(G, None, 10000, "unique")
    mhrw = common.metropolis_hastings_random_walk(G, None, 10000, "unique")
    # print round(1/impore - 1, 4)
    # 保存数据
    f = open("../compare/alpha_dup/com_dup.txt", "w")
    try:
        f.write(str("rw") + " " + str(rw) + "\n")
        f.write(str("mhrw") + " " + str(mhrw) + "\n")
    finally:
        f.close()
コード例 #4
0
def alpha_press():
    f = FaceData()
    G = f.create_graph()  # 获取原始数据

    impore = improve_MH.impore_03(G, None, 10000, "unique")
    # print round(1/impore - 1, 4)
    # 保存数据
    f = open("../compare/alpha_dup/a_dup.txt", "w")
    try:
        for i in xrange(5, 100, 5):
            i = float(i) / 100
            print i
            dup = 0
            for j in xrange(0, 10):
                dup += improve_MH.impore_03(G, None, 10000, "unique", alpa=i)
            dup /= 10
            f.write(str(i) + " " + str(dup) + "\n")
            print dup
    finally:
        f.close()