import matplotlib.pyplot as plt
import networkx as nx
G1=nx.Graph()# 创建空的无向图
G1.add_weighted_edges_from...minWPath_v1_v11=nx.dijkstra_path(G1,source=1,target=11)# 顶点1到顶点11的最短加权路径
print("顶点 v1 到 顶点 v11 的最短加权路径...11)#最短加权路径长度
print("顶点 v1 到 顶点 v11 的最短加权路径长度: ",lMinWPath_v1_v11)
pos={1:(0,4),2:(5,7),3:(5,4),4:(5,1...:(15,7),9:(15,4),10:(15,1),11: (20,4)}# 指定顶点位置
labels=nx.get_edge_attributes(G1,'weight')#设置边的labels为weight...nx.draw(G1,pos,with_labels=True,font_color='w')#绘制无向图
nx.draw_networkx_edge_labels(G1,pos,edge_labels