以下为Python代码:

import networkx as nx
import matplotlib.pyplot as pltG = nx.Graph() G.add_nodes_from([1,2,3,4,5]) G.add_edges_from([(1,2),(1,3),(2,4),(3,4),(3,5),(4,5)]) nx.draw(G, with_labels=True) plt.show()