findShortestPath method

Future<ShortestPathResponse> findShortestPath(
  1. String sourceKref,
  2. String targetKref, {
  3. List<String>? edgeTypeFilter,
  4. int? maxDepth,
  5. bool allShortest = false,
})
inherited

Finds the shortest path between two revisions.

sourceKref is the starting revision. targetKref is the destination revision. edgeTypeFilter filters by edge types (empty for all). maxDepth limits search depth (default: 10). allShortest returns all shortest paths instead of just one.

Implementation

Future<ShortestPathResponse> findShortestPath(
  String sourceKref,
  String targetKref, {
  List<String>? edgeTypeFilter,
  int? maxDepth,
  bool allShortest = false,
}) async {
  final request = ShortestPathRequest()
    ..sourceKref = Kref(uri: sourceKref)
    ..targetKref = Kref(uri: targetKref)
    ..allShortest = allShortest;
  if (edgeTypeFilter != null && edgeTypeFilter.isNotEmpty) {
    request.edgeTypeFilter.addAll(edgeTypeFilter);
  }
  if (maxDepth != null) {
    request.maxDepth = maxDepth;
  }
  return stub.findShortestPath(request, options: callOptions);
}