putEdge method

E putEdge(
  1. V source,
  2. V target,
  3. E ifAbsent()
)

Look up the value of the edge between source and target, or add a new edge with the value of ifAbsent if it isn't there.

Implementation

E putEdge(V source, V target, E Function() ifAbsent) {
  final edge = getEdge(source, target);
  if (edge != null) return edge.value;
  final value = ifAbsent();
  addEdge(source, target, value: value);
  return value;
}