Dijkstra算法最短路径
我正在尝试构建一个最短路径程序,但我对图表有疑问。是不是要先画图???我还能如何定义哪些节点是邻居???
I'm attempting to build a shortest path program and I have a question about the graph. Are you supposed to draw the graph first??? How else would I define which nodes are neighbors???
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我假设你的意思是编程。
您可以通过用于存储图形以供程序处理它的结构来定义图形中的相邻节点。有几个选项:例如邻接矩阵、邻接列表和关联矩阵 。
I assume you mean programatically.
You define the adjacent nodes in your graph by the structure that you use to store the graph for your program to process it. There are several options: adjacency matrix, adjacency lists and incidence matrix for example.
“绘图”与该算法无关。
该图通常表示为节点列表(编号为 1..n)和边列表(有序对源节点 # -> 目的地节点 #)。
还使用了其他表示形式,例如每个节点具有列和行的矩阵。
"Drawing" has nothing to do with this algorithm.
The graph is typically represented as a list of nodes (numbered 1..n) and a list of edges (ordered pairs source node # -> destination node #).
Other representations have been used such as a matrix with a column and row for each node.