asWeighted method
- double weight(
- E source,
 - E target
 
 
Returns a view of this walkable as a weighted walkable.
The weight function is used to determine the weight of an edge between
two nodes, and is invoked with the source and target nodes of the edge
each time the edge is accessed.
Example
final unweighted = Walkable.generate(
  successors: (node) => switch (node) {
    'a' => ['b'],
    _ => const [],
  },
  roots: () => ['a'],
);
final weighted = unweighted.asWeighted((source, target) => 1);
print(weighted.successors('a')); // [('a', 1)]
Implementation
WeightedWalkable<E> asWeighted(
  double Function(E source, E target) weight,
) {
  return _AsWeightedWalkable(this, weight);
}