from research import *
s=begin(864,'Compare the restored common name graph','Does inserting the admitted Cainan equate the two measurements?',{'MT_Cainan_interval':130,'NT_slot':70},['C831 admitted Cainan insertion','C862–863'])
f=json.loads((ROOT/'model/NT_MT_field.json').read_text())
out=[]
for i,r in enumerate(f):
 mt=r['MT_rounded']+(130 if i<=11 else 0)
 out.append({'name':r['name'],'NT':r['NT'],'MT':mt,'G':r['NT']-mt})
 if r['name']=='Arphaxad':
  mt_c=f[i+1]['MT_rounded']+130
  out.append({'name':'Cainan','NT':4416,'MT':mt_c,'G':4416-mt_c})
edges=[{'from':a['name'],'to':b['name'],'NT':a['NT']-b['NT'],'MT':a['MT']-b['MT']} for a,b in zip(out,out[1:])]
a=artifact('model/NT_MT_Cainan_restored.json',json.dumps({'nodes':out,'edges':edges},indent=2)+'\n')
finish(s,{'restored':a,'local_edges':edges[11:13],'local_G':[r['G'] for r in out[11:14]]},'Restoration yields the same 23-name graph but different edge weights: 70|70 in NT and 35|130 in restored MT. Topological alignment does not require equal durations.','Transfer the Actual-to-Rounded residual theorem across the whole native comparison.',{'names':len(out)==23,'NT_uniform':all(e['NT']==70 for e in edges),'local_MT':[e['MT'] for e in edges[11:13]]==[35,130],'net':out[11]['G']-out[13]['G']==140-165})
