Exemple #1
0
def generatePCvs(times, n, beta, s):
    i = 0
    vs = []
    while i < times:
        g = PC(n, beta)
        if isConnected(g):
            vs += getMs(g, s)
            sys.stdout.write("\rGenerating graphs: {}/{} finished".format(i + 1, times))
            i += 1
    assert len(vs) == times * n
    return vs
def generateSBwalk2vec(times, n, delta, s):
    path = input("Enter filename to save SB datasets...\n")
    with open(path, 'w') as f:
        try:
            i = 0
            while i < times:
                g = SB(n, delta)
                if isConnected(g):
                    v = walk2vec(g, s)
                    f.write(str(v) + '\n')
                    sys.stdout.write("\r{}/{} finished".format(i + 1, times))
                    i += 1
        except:
            os.remove(path)
            traceback.print_exc()
            exit(1)

    print("\rData successfully generated")