graph_shortest_path 函数
返回两个顶点之间的一条最短路径。
语法
GraphTheory:-ShortestPath(edges, source, target)graph_shortest_path(edges, source, target)
参数与选项
edges | 形如 [[u, v], ...] 的边列表。 |
|---|---|
source | 起点顶点。 |
target | 终点顶点。 |
示例
- 最短路径
GraphTheory:-ShortestPath([[a, b], [b, c], [c, a], [c, d]], a, d)返回 [a, c, d]。