Example #1
0
def translate_e(tokens, num_vert):
    s, s2 = [], []
    for token in tokens:
        s.append("; (e" + bp.name(int(token[1]), num_vert) +\
                     bp.name(int(token[2]), num_vert) + \
                     ')')
        s2.append("(not_e" + bp.name(int(token[1]), num_vert) +\
                     bp.name(int(token[2]), num_vert) + \
                     ')')
    return s, s2
Example #2
0
def generate_random_e(n, p):
    random.seed(seed)
    s = []
    for i in range(1,n+1):
        for j in range(1,n+1):
            r = random.random()
            x = bp.name(i, n)
            y = bp.name(j, n)
            if r <= p:
                s.append("(e" + x + y + ")")
    return s
Example #3
0
def generateRandomInput(n, p):
    random.seed(seed)
    s = []
    for i in range(1, n + 1):
        for j in range(1, n + 1):
            for k in range(1, n + 1):
                x = random.random()
                if x <= p:
                    s.append("(t" + bp.name(i, n) +\
                            bp.name(j, n) + bp.name(k, n) + ")")
    return s
Example #4
0
def generate_random_e(n, p):
    random.seed(seed)
    s = []
    for i in range(1, n + 1):
        for j in range(1, n + 1):
            r = random.random()
            x = bp.name(i, n)
            y = bp.name(j, n)
            if r <= p:
                s.append("(e" + x + y + ")")
    return s
Example #5
0
def generateRandomInput(n, p):
    random.seed(seed)
    s = []
    for i in range(1,n+1):
        for j in range(1,n+1):
            for k in range(1,n+1):
                x = random.random()
                if x <= p:
                    s.append("(t" + bp.name(i, n) +\
                            bp.name(j, n) + bp.name(k, n) + ")")
    return s
Example #6
0
def generate_random_e(n, p):
    random.seed(seed)
    s = []
    e_set = set()
    for i in range(1,n+1):
        for j in range(i+1,n+1):
            r = random.random()
            x = bp.name(i, n)
            y = bp.name(j, n)
            if r <= p and (x, y) not in e_set:
                s.append("(e" + x + y + ")")
                e_set.add((x, y))
                e_set.add((y, x))
    return s
Example #7
0
def generate_random_e(n, p):
    random.seed(seed)
    s = []
    e_set = set()
    for i in range(1, n + 1):
        for j in range(i + 1, n + 1):
            r = random.random()
            x = bp.name(i, n)
            y = bp.name(j, n)
            if r <= p and (x, y) not in e_set:
                s.append("(e" + x + y + ")")
                e_set.add((x, y))
                e_set.add((y, x))
    return s
Example #8
0
def generate_not_k(k):
    if k > num_vert:
        print "Error: k is greater than the number of vertices"
    s = []
    for i in range(k+1, num_vert+1):
        s.append("(not_k" + bp.name(i, num_vert) + ")")
    return s
Example #9
0
def generate_k(k):
    if k > num_vert:
        print "Error: k is greater than the number of vertices"
    s = []
    for i in range(1, k + 1):
        s.append("(k" + bp.name(i, num_vert) + ")")
    return s
Example #10
0
def translate_e(tokens, num_vert):
    s, s2 = [], []
    for token in tokens:
        s.append("; (e" + bp.name(int(token[1]), num_vert) + bp.name(int(token[2]), num_vert) + ")")
        s2.append("(not_e" + bp.name(int(token[1]), num_vert) + bp.name(int(token[2]), num_vert) + ")")
    return s, s2