# packages is all you needimport seaborn as sns
from bs4 import BeautifulSoup
import re
import requests
import json
import pandas as pd
import matplotlib.pyplot as plt
data =[]#初始化#使用with语句优势:1.自动关闭文件句柄;2.自动显示(处理)文件读取数据异常withopen("arxiv-metadata-oai-2019.json",'r')as f:for idx, line inenumerate(f):
d = json.loads(line)
d ={'authors_parsed': d['authors_parsed']}
data.append(d)
data = pd.DataFrame(data)#将list变为dataframe格式,方便使用pandas进行分析
import networkx as nx
# 创建无向图
G = nx.Graph()# 只用五篇论文进行构建for row in data.iloc[:5].itertuples():
authors = row[1]
authors =[' '.join(x[:-1])for x in authors]# 第一个作者 与 其他作者链接for author in authors[1:]:
G.add_edge(authors[0],author)# 添加节点2,3并链接23节点
# packages is all you needimport seaborn as snsfrom bs4 import BeautifulSoupimport reimport requests import jsonimport pandas as pdimport matplotlib.pyplot as pltdata = [] #初始化#使用with语句优势:1.自动关闭文件句柄;2.自动显示(处理)文件读取数据异常with open("arxiv-metadata-o