shortestPath<T extends Object> function

Iterable<T>? shortestPath<T extends Object>(
  1. T start,
  2. T target,
  3. Iterable<T> edges(
    1. T
    ), {
  4. bool equals(
    1. T,
    2. T
    )?,
  5. int hashCode(
    1. T
    )?,
})

Returns the shortest path from start to target given the directed edges of a graph provided by edges.

If start == target, an empty List is returned and edges is never called.

If equals is provided, it is used to compare nodes in the graph. If equals is omitted, the node's own Object.== is used instead.

Similarly, if hashCode is provided, it is used to produce a hash value for nodes to efficiently calculate the return value. If it is omitted, the key's own Object.hashCode is used.

If you supply one of equals or hashCode, you should generally also to supply the other.

Implementation

Iterable<T>? shortestPath<T extends Object>(
  T start,
  T target,
  Iterable<T> Function(T) edges, {
  bool Function(T, T)? equals,
  int Function(T)? hashCode,
}) =>
    _shortestPaths<T>(
      start,
      edges,
      target: target,
      equals: equals,
      hashCode: hashCode,
    )[target];