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
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
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
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
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
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
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
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
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
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