我有这本词典,里面有两本词典
tdict={'a1':{
'aa1':{'aaa101':{'information'},'aaa201':{'information'}},
'aa2':{'cca101':{'information'},'aca201':{'information'}},
'ab1':{'aasdfaa101':{'information'},'aadaa201':{'information'}}
}
,'a2':{
'ab1':{'aasdfaa101':{'information'},'aadaa201':{'information'}},
'ab2':{'zz101':{'information'},'azz201':{'information'}},
'ac2':{'aaa101':{'information'},'aaa201':{'information'}}
}
,'a3':{
'ac1':{'aaa101':{'information'},'aaa201':{'information'}},
'ac2':{'aaa101':{'information'},'aaa201':{'information'}}
}}
我想绘制网络图并查看连接到的每个节点,我使用了来自networkx
的from_dict_of_dicts
方法,它可以工作,但它不显示最终的dict,例如aaa201,aaa101
,而只显示这两个值的键
如何将节点aaa201,zz101
包含在同一个绘图中
可以使用递归遍历字典,并使用节点和相应边填充图形:
输出:
相关问题 更多 >
编程相关推荐