def vertex_cover_tree(input_graph): n = len(input_graph) assignment = [None]*n return recursive_vertex_cover(input_graph, assignment) def recursive_vertex_cover(input_graph, assignment): n = len(input_graph) v = -1 for i in range(n): if assignment[i] == None: v = i for j in range(i, n): if input_graph[i][j] == 1: if assignment[i] == 0 and assignment[j] == 0: return float("inf") if v == -1: size = 0 for i in range(n): if assignment[i] == 1: size += 1 return size assignment[v] = 0 size_v_0 = recursive_vertext_cover