我有以下带有节点的网络:“ a”,“ b”,“ c”,并且这些节点具有不同的边,且具有不同的权重(“ count”)。我如何创建一个函数,该函数需要一个节点并为我提供最大权重的相应color(edge)?
import networkx as nx
G = nx.Graph()
nodes = ['a', 'b', 'c']
edges = [('a', 'red', {'count': 4}),
('a', 'blue', {'count': 12}),
('a', 'orange', {'count': 33}),
('b', 'purple', {'count': 4}),
('b', 'red', {'count': 11}),
('c', 'red', {'count': 9}),
('c', 'orange', {'count': 6}),
('c', 'yellow', {'count': 7})]
G.add_nodes_from(nodes)
G.add_edges_from(edges)