WeightedWalkable<E>.from constructor

const WeightedWalkable<E>.from(
  1. Map<E, Iterable<(E, double)>> edges
)

Creates a walkable from a map of source nodes to target nodes and weights.

The resulting walkable is lazy, and is generally inefficient for operations outside of iterating edges. This is a convenience method for creating a walkable from a collection of edges, i.e. in a test case.

Example

final walkable = WeightedWalkable.fromEdges({
  'a': [('b', 1)],
  'b': [('c', 2)],
  'c': [('d', 3)],
});
print(walkable.edges); // {a -> b (1.0), b -> c (2.0), c -> d (3.0)}

Implementation

const factory WeightedWalkable.from(
  Map<E, Iterable<(E, double)>> edges,
) = _EdgesWeightedWalkable<E, double>;