aryagraph.core.utils.weight_fn#

aryagraph.core.utils.weight_fn(weight: str | Callable[[Hashable, Hashable, dict], float] | None, default: float = 1.0) → Callable[[Hashable, Hashable, dict], float][source]#

Normalise a weight argument into f(u, v, attrs) -> float.

None means every edge weighs default; a string names an edge attribute (edges without it weigh default); a callable is used as is.