"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const map = require("../lodash-es/map.cjs");
const reduce = require("../lodash-es/reduce.cjs");
function barycenter(g, movable) {
  return map.default(movable, function(v) {
    var inV = g.inEdges(v);
    if (!inV.length) {
      return { v };
    } else {
      var result = reduce.default(
        inV,
        function(acc, e) {
          var edge = g.edge(e), nodeU = g.node(e.v);
          return {
            sum: acc.sum + edge.weight * nodeU.order,
            weight: acc.weight + edge.weight
          };
        },
        { sum: 0, weight: 0 }
      );
      return {
        v,
        barycenter: result.sum / result.weight,
        weight: result.weight
      };
    }
  });
}
exports.barycenter = barycenter;
//# sourceMappingURL=src-dagre-order-barycenter.cjs.map
