import pandas as pd
import numpy as np
import networkx as nx
import matplotlib.pyplot as plt
from random import randint
import itertools
读取数据集 && 构建networkx矩阵
facebook = pd.read_csv("./out.ego-facebook" , sep=' ', names=['start_node', 'end_node'])
G = nx.from_pandas_edgelist(facebook, 'start_node', 'end_node')
绘制ego-facebook的图像
fig, ax = plt.subplots(figsize=(15, 9))
ax.axis('off')
plot_options = {
"node_size": 10, "with_labels": False, "width": 0.15}
nx.draw_networkx(G, pos=nx.random_layout(G), ax=ax, **plot_options)
plt.show()
pos = nx.spring_layout(G, iterations=15, seed=1721)
fig, ax = plt.subplots(figsize=