MathTop

graph_distance 函数

返回两个顶点之间的最短路距离。

语法

  • GraphTheory:-Distance(edges, source, target)
  • graph_distance(edges, source, target)

参数与选项

edges形如 [[u, v], ...] 的边列表。
source起点顶点。
target终点顶点。

示例

  1. 顶点距离GraphTheory:-Distance([[a, b], [b, c], [c, a], [c, d]], a, d)返回 2。