我想使用Python中的NetworkX获得k-shell算法最内核中对应于最高度的 node .我try 使用以下代码获取 node ,但遇到错误"AttributeError:'DiGraph'对象没有属性'keys'"
# Create a digraph
G = nx.DiGraph()
G.add_edge(1,2,weight=673)
G.add_edge(2,4,weight=201)
G.add_edge(4,1,weight=20)
G.add_edge(2,3,weight=96)
G.add_edge(3,4,weight=44)
G.add_edge(6,3,weight=7)
G.add_edge(6,4,weight=96)
G.add_edge(5,6,weight=10)
G.add_edge(7,6,weight=10)
G.add_edge(8,6,weight=10)
# Calculate k-shells
shells = nx.algorithms.core.k_shell(g)
# Find the maximum k-shell value
max_k_shell = max(k_shells.keys())
# Get the nodes in the most inner core
inner_core_nodes = k_shells[max_k_shell]
# Print the nodes in the most inner core
print(inner_core_nodes)