import { asNonCompoundGraph, buildLayerMatrix } from "./src-dagre-util.js";
import { positionX } from "./src-dagre-position-bk.js";
import forOwn from "../lodash-es/forOwn.js";
import forEach from "../lodash-es/forEach.js";
import max from "../lodash-es/max.js";
import map from "../lodash-es/map.js";
function position(g) {
  g = asNonCompoundGraph(g);
  positionY(g);
  forOwn(positionX(g), function(x, v) {
    g.node(v).x = x;
  });
}
function positionY(g) {
  var layering = buildLayerMatrix(g);
  var rankSep = g.graph().ranksep;
  var prevY = 0;
  forEach(layering, function(layer) {
    var maxHeight = max(
      map(layer, function(v) {
        return g.node(v).height;
      })
    );
    forEach(layer, function(v) {
      g.node(v).y = prevY + maxHeight / 2;
    });
    prevY += maxHeight + rankSep;
  });
}
export {
  position
};
//# sourceMappingURL=src-dagre-position-index.js.map
