Modification of shortest path algorithm (route from a node to itself)

这一生的挚爱 提交于 2019-12-05 13:06:24

Changing the diagonal elements adjacency matrix from 0 to infinity (theoretically) should work.

It means the self loop cost is infinite and any other path with less than this cost is better hence if a path exists from a node to itself, through other nodes, its cost will be finite and it will replace the infinite value.

Practically you can use maximum value of integer as infinite.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!