import e from "../../../../lodash-es/map.js";
import t from "../../../../lodash-es/reduce.js";
//#region ../../node_modules/dagre-d3-es/src/dagre/order/barycenter.js
function n(n, r) {
	return e(r, function(e) {
		var r = n.inEdges(e);
		if (r.length) {
			var i = t(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 };
	});
}
//#endregion
export { n as barycenter };
