def Special_Case4_Occurance(): max_repeats = 1000 max_nodes = 10 n = 2 repeat = True case4 = [] while repeat == True: for repeats in range(max_repeats): G = random_graph_generator(n, n * 3) sc4 = special_4_check(G) case4.append(sc4) case4_occur = case4.count(True) case4 = [] print(str(n) + "\t" + str(case4_occur / max_repeats)) if n == max_nodes: repeat = False n += 1
def Special_Case3_Occurance(): max_repeats = 1000 max_nodes = 10 n = 2 repeat = True case3 = [] while repeat == True: for repeats in range(max_repeats): G = random_graph_generator(n, (n * (n - 1)) / 2) sc3 = special_3_check(G, n) case3.append(sc3) case3_occur = case3.count(True) case3 = [] print(str(n) + "\t" + str(case3_occur / max_repeats)) if n == max_nodes: repeat = False n += 1
def Greedy_Approximation(): print("n\tApproximation") max_repeats = 1000 max_nodes = 1000 n = 100 repeat = True approx = [] while repeat == True: for repeats in range(max_repeats): G = random_graph_generator(n, n * 2) a = Perc_Hamiltonian(Greedy_Search(G)) approx.append(a) approx_final = sum(approx) approx = [] print(str(n) + "\t" + str((approx_final / max_repeats))) points_n.append(n) points_a.append(approx_final / max_repeats) if n == max_nodes: repeat = False n += 100
def __init__(self, nNodes, nEdges): self.graph = random_graph_generator(nNodes, nEdges) self.solution = None self.graspCurrentSolution = None self.neighbourArray = []