来自 python 元组的 NetworkX 图

NetworkX graph plot from python tuple

在我下面的新元组中:

我怎样才能让编号最大的 "string" 成为头节点,其他字符串名称附加到它们的编号上。

new = (('COCH', 8), ('CAB', 4), ('VSNL', 7), ('ZNRF', 8), ('SLC12A1', 4), 
('APC', 16), ('LOC', 8), ('TRPM', 4), ('TNFRSF', 22))

在我上面的元组中,如何将最高数字 (22) "TNFRSF" 作为节点,所有其他字符串都附加到该节点。连接宽度是它们各自的数字。例如,“COCH”连接到宽度为 8 的 "TNFRSF" 节点。

import networkx as nx

new = (('COCH', 8), ('CAB', 4), ('VSNL', 7), ('ZNRF', 8), ('SLC12A1', 4), ('APC', 16), ('LOC', 8), ('TRPM', 4), ('TNFRSF', 22))
children = sorted(new, key=lambda x: x[1])
parent = children.pop()[0]

G = nx.Graph()
for child, weight in children: G.add_edge(parent, child, weight=weight)
width = list(nx.get_edge_attributes(G, 'weight').values())
nx.draw_networkx(G, width=width)