发布于 2021-12-11 16:08:04
若要使图形无向,需要将每个键添加为值,如果该键尚未出现:
for k,l in d.items():
for e in l:
if k not in d[e]:
d[e].append(k)产出:
{1: [4, 3, 5],
2: [3],
3: [1, 6, 2],
4: [6, 1],
5: [1, 6],
6: [5, 3, 4]}https://stackoverflow.com/questions/70316636
复制相似问题