获取可能的路线和两个给定点之间的距离

Getting the possible routes and the distance between two given points

我有一个非常具有挑战性的任务。

我需要创建一个 PHP 函数来列出两个给定点之间的所有路线,并按最短距离排序。 例如A点和E点的路线是什么。列出所有按距离排序的路线。

我把它列成这样:

    A   B   C   D   E
A   0   5   9   10  29
B   5   0   9   11  13
C   9   9   0   1   9
D   10  11  1   0   10
E   29  13  9   10  0

A​​到B的距离是5,A到C的距离是9等等。

请帮忙。非常感谢!

您需要实施 Dijkstra's algorithm, as this topic is really old and well discussed on the internet, i won't try to reinvent the wheel and try to copy paste bunch of text. Possible php implementations can be found here or here