Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- y = var('y')
- '''
- Group Members
- =============
- '''
- userids = ['Thormundur15'] # fill in this array with strings of usernames
- def m5p1(G):
- '''Return the size of the largest clique
- '''
- maxcount = 1
- for i in G:
- stack = [i]
- for j in G[i]:
- if(set(stack) <= set(G[j])):
- stack.append(j)
- if(len(stack) > maxcount):
- maxcount = len(stack)
- return maxcount
- def myfunction(stack, constack, G):
- diff = list(set(stack) - set(G))
- for i in diff:
- if(i not in stack and i not in constack):
- newstack [i]
- newconstack = []
- for j in stack:
- newstack.append(j)
- for j in constack:
- newconstack.append(j)
- for j in G[i]:
- newconstack.append(j)
- myfunction(newstack, newconstack, G)
- return len(stack)
- def m5p2(G):
- '''Return the size of the largest independent set
- '''
- largest = 1
- for i in G:
- independentSet = [i]
- listSC = [i]
- for k in G[i]:
- listSC.append(k)
- count = 0
- oArr = G.copy()
- for k in range(0, i):
- temp = oArr[0]
- for j in xrange(0, len(oArr)-1):
- oArr[j] = oArr[j+1]
- oArr[len(oArr)-1] = temp
- for k in oArr:
- if(k not in listSC):
- independentSet.append(k)
- count += 1
- if(k in independentSet):
- for j in oArr[k]:
- listSC.append(j)
- if(largest < count):
- largest = count
- return largest
- def lowCost(U, S, cost, Allcost):
- if(len(U) == 0):
- Allcost.append(cost)
- return cost
- else:
- for i in range(len(S)):
- for j in range(len(S[i])):
- if(S[i][j] in U):
- lowCost(list(set(U) - set(S[i])), S, cost+1, Allcost)
- break
- return min(Allcost)
- def m5p3(U, S):
- '''Return the lowest number of subsets from S to cover U
- '''
- return lowCost(U, S, 0, [])
- def m5p4(xmin, xmax, ymin, ymax):
- '''Return a lambda function for the square bounded by xmin-xmax and ymin-ymax
- '''
- return lambda px, py: px >= xmin and px <= xmax and py >= ymin and py <= ymax
- def m5p5(x0, y0, r):
- '''Return a lambda function for the square with center (x0, y0) and side length 2r
- '''
- return lambda px, py: px >= x0 - r and px <= x0 + r and py >= y0 - r and py <= y0 + r
- def m5p6(x0, y0, r):
- '''Return a lambda function for the disc with center (x0, y0) and radius r
- '''
- return lambda px, py: True
- def m5p7((a0, b0, r), n=5000, xmin=-1, xmax=1, ymin=-1, ymax=1):
- '''Return an approximation of the area covered by P (a disc) inside the rectangle
- '''
- return -1
- def m5p8(f, n=1000, xmin=-1, xmax=1, ymin=-1, ymax=1, zmax=1):
- '''Return an approximation of the volume between the function and the xy-plane
- '''
- return -1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement