from collections import defaultdict def run(load,read,check): d=load('C446_DATA.json');adj=defaultdict(list);loops=[] for e in d['edges']: x,y,c=e['lower'],e['upper'],e['center'] if x==y:loops.append({'point':x,'center':c,'affine_slope':-1,'affine_intercept':2*c});continue adj[x].append((y,c));adj[y].append((x,c)) cycles={} for start in sorted(adj): def visit(path,centers): x=path[-1] for y,c in adj[x]: if y==start and len(path)>=3: vs=tuple(path);rev=(start,)+tuple(reversed(path[1:]));key=min(vs,rev) if key!=vs:continue cs=centers+[c];s,t=1,0 for cc in cs:s,t=-s,2*cc-t cycles[key]={'vertices':list(vs)+[start],'centers':cs,'length':len(cs),'affine_slope':s,'affine_intercept':t,'global_affine_identity':s==1 and t==0} elif y>start and y not in path:visit(path+[y],centers+[c]) visit([start],[]) for i,p in enumerate(cycles.values()):check(f'cycle_{i}',p['affine_slope']*p['vertices'][0]+p['affine_intercept']==p['vertices'][0]) check('cycle rank',len(d['edges'])-373+len(d['components'])==len(loops)+len(cycles)) return {'step':'C448','simple_cycles':list(cycles.values()),'fixed_point_loops':loops,'counts':{'ordinary_simple_cycles':len(cycles),'fixed_loops':len(loops),'cycle_rank_including_loops':len(d['edges'])-373+len(d['components'])},'limits':'A global affine identity can still be admitted only on a small partial source domain.'}