我有大约10,000个出版物有入站或/和出站引用。
数据格式如下(以两个条目为例):
# each 'number' is a 'paper_id'
citations = {
'157553241': {
'inbound_citations': [],
'outbound_citations': [
'141919793',
'158546657',
'156580052',
'159778536',
'157021328',
'158546657',
'157021328',
'141919793',
'153005744',
'159778536',
'112335878',
'156580052'
]
},
'54196724': {
'inbound_citations': ['204753337', '55910675'],
'outbound_citations': ['153776751', '141060228', '33718066', '158233543']
},
}如何将此格式转换为可以提供给networkx的格式
我想找到最“核心”的论文,并发现一些小团体(首先)。
我试过了
G = nx.DiGraph(citations)但我不认为它是那样的.
发布于 2021-08-07 19:23:49
您需要构建一个边列表,如下所示:
import networkx as nx
import matplotlib.pyplot as plt
edges = []
for node in citations:
for parent in citations[node]['inbound_citations']:
edges.append((parent, node))
for child in citations[node]['outbound_citations']:
edges.append((node, child))
G = nx.DiGraph()
G.add_edges_from(edges)
nx.draw(G, with_labels=True)
plt.show()

https://stackoverflow.com/questions/68695444
复制相似问题