Question: Please help me find the problem and fix it def find ( u ) : global parent if ( u = = parent [ u
Please help me find the problem and fix it
def findu:
global parent
ifu parentu:
return u
parentu findparentu
return parentu
# Read in the number of vertices n and edges m
n intinput
m intinput
edges
nedges for i in rangen for j in rangen
for i in rangem:
u v w inputsplit
u intu
v intv
w floatw
edges.appenduvw
nedgesuvw
nedgesuvw
sortedeg sortededges keylambda x: x
parenti for i in rangen
count intinput
costs
for i in rangecount:
uv inputsplit
u intu
v intv
parentu findu
parentv findv
parentparentuparentv
costs nedgesuv
q
for u v w in sortedeg:
parentu findu
parentv findv
if parentu parentv:
parentparentu parentv
q w
result q costs
printroundresult
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
