这是此处帖子的后续内容。
我正在尝试将从 Scipy 的 Delaunay 三角剖分返回的单纯形转换为 Networkx 图。
代码:
from scipy.spatial import Delaunay as scipy_Delaunay
# tri = scipy_Delaunay(pts[:, 0:2]) #input points
# simplices = tri.simplices
simplices = np.array([[ 9, 13, 19],
[11, 9, 4],
[ 9, 11, 13],
[ 0, 7, 2],
[ 7, 3, 18]])
G = nx.Graph(simplices)
for path in simplices:
nx.add_path(G, path)
nx.draw(G, with_labels=True, node_size=500, node_color='lightgreen')
错误:
raise nx.NetworkXError(f"Adjacency matrix not square: nx,ny={A.shape}")
networkx.exception.NetworkXError: Adjacency matrix not square: nx,ny=(5, 3)
networkx.exception.NetworkXError: Input is not a correct numpy matrix or array.
我不确定如何解决此错误。建议将非常有帮助。