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