Question: VfyThirdNodeCover - to _ complete.pyfrom graph import Graphfrom math import floorV 3 NCv = 'VERBOSE: VfyThirdNodeCove ( ) - 'VERBOSE = Truedef printV ( text

VfyThirdNodeCover-to_complete.pyfrom graph import Graphfrom math import floorV3NCv = 'VERBOSE: VfyThirdNodeCove()- 'VERBOSE = Truedef printV(text): if VERBOSE: print(f'{V3NCv}{text}') returnV3NCd = 'DEV: VfyThirdNodeCove()- 'DEV = Falsedef printD(text): if DEV: print(f'{V3NCd}{text}') returndef VfyThirdNodeCover(I,S,H): if False: # ** MIDTERM 2: Change conditional to something reasonable printV(f'Invalid solution size: {len(S)}') return 'unsure' if False: printV(f'Invalid hint size: {len(H)}') return 'unsure' g = Graph(I, weighted=False, directed=False) nodes = list(g.nodes.keys()) edges =[str(edge) for edge in g.edges()] printD(f'edges: {edges}') # H is a white-space delimited list of nodes nc = H.split() nc_size = len(nc) # ** MIDTERM #2: Add other reasons to be unsure. return 'correct'if __name__=='__main__': def test_case(func,I,S,H,expected,num,comment=''): err ='**' result = func(I,S,H) func_name = str(func).split()[1] func_call = f'''{func_name}("{I}","{S}","{H}")''' if result == expected: err ='' e = expected print (f'{err}test #{num}{func_call}: expected "{e}", received "{result}"') print (f'test #{num} Explanation: {comment}
') return num +1 F = VfyThirdNodeCover I ='a,b a,c b,c;2' num =1 exp = 'solution too long' num = test_case(F,I,'maybe','a b','unsure',num,exp) I ='a,b a,c b,c;1' exp ='|{a,b}|=2> floor(len(nodes)/3)' num = test_case(F,I,'yes','a b','unsure',num,exp) I ='a,b a,c b,c;2' exp = 'a does not cover b-c' num = test_case(F,I,'yes','a','unsure',num,exp) I ='a,b a,c' num =1 exp = 'a covers all edges, and |{a}|=1= floor(len(nodes)/3)' num = test_case(F,I,'yes','a','correct',num,exp) # From PolyReduceThirdNodeCoverToHalfClique I ='a,b a,c c,d' exp ='|{a,c}|> floor(|nodes|/3)' num = test_case(F,I,'yes','a c','unsure',num,exp) I ='a,b c,d e,f' exp ='|{a,b,c}|> floor(|nodes|/3)' num = test_case(F,I,'yes','a b c','unsure',num,exp) I ='a,b a,c a,d a,e a,f f,g' exp ='{a} does not cover all the nodes in the graph' num = test_case(F,I,'yes','a','unsure',num,exp) I ='a,b a,c d,e d,f d,g' exp ='|{a,c} does not cover all the nodes in the graph' num = test_case(F,I,'yes','a c','unsure',num,exp) I ='a,b a,c d,e d,f d,g e,h' exp ='|{a,d,e}|> floor(|nodes|/3)' num = test_case(F,I,'yes','a d e','unsure',num,exp) I ='a,b b,c' exp ='|{a}| does not cover graph' num = test_case(F,I,'yes','a','unsure',num,exp) I='a,b a,c' exp ='|{a}|1/3 nodes in graph' num = test_case(F,I,'yes','a','correct',num,exp) I ='a,b a,c d,e d,f' exp ='|{a,d|= floor(|nodes|/3)' num = test_case(F,I,'yes','a d','correct',num,exp) I ='a,b a,c a,d a,e a,f' exp ='|{a}| floor(|nodes|/3)' num = test_case(F,I,'yes','a','correct',num,exp) I ='a,b a,c d,e d,f d,g' exp ='|{a,d}| floor(|nodes|/3)' num = test_case(F,I,'yes','a d','correct',num,exp) I ='a,b a,c a,d a,e a,f a,g' exp ='|{a}| floor(|nodes|/3)' num = test_case(F,I,'yes','a','correct',num,exp) I ='a,b a,c d,e d,f d,g d,h' exp ='|{a,d}| floor(|nodes|/3)' num = test_case(F,I,'yes','a d','correct',num,exp) I ='a,b a,c a,d a,e a,f a,g a,h' exp ='|{a}| floor(|nodes|/3)' num = test_case(F,I,'yes','a','correct',num,exp)
Below is the define thirdnode
expected and actual results in the test cases is a good sign. Bear in mind that stance I' of Hyon implementation is to map an instance I of ThirdNodeCover onto an stance of Thirdifique, such that I' is a positive instance of HalfClique iff I is a positive
node cover is a subset of the nodes in an unweighted, undirected graph (specified as a white ace delimited sequence of edges), such that every edge in the graph has one or both idpoints in a node in the subset.
instance of ThirdNodeCover is an unweighted, undirected graph as defined above. It is a positive tance if the graph contains a node cover subset S, such that |S| floor(N/3), where N is the mber of nodes in the graph. For example, 'a,ba,cd,ed,fd,g' is a positive instance of irdNodeCover because it defines a graph with 7 nodes, {a,d} is a node cover subset, and |{a,d}|2= floor
VfyThirdNodeCover - to _ complete.pyfrom graph

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Accounting Questions!