import map_default from "../../../../lodash-es/map.js";
import reduce_default from "../../../../lodash-es/reduce.js";
function barycenter(n, r) {
	return map_default(r, function(e) {
		var r = n.inEdges(e);
		if (r.length) {
			var i = reduce_default(r, function(e, t) {
				var r = n.edge(t), i = n.node(t.v);
				return {
					sum: e.sum + r.weight * i.order,
					weight: e.weight + r.weight
				};
			}, {
				sum: 0,
				weight: 0
			});
			return {
				v: e,
				barycenter: i.sum / i.weight,
				weight: i.weight
			};
		} else return { v: e };
	});
}
export { barycenter };
