import forEach from "../lodash-es/forEach.js";
import min from "../lodash-es/min.js";
import map from "../lodash-es/map.js";
function longestPath(g) {
  var visited = {};
  function dfs(v) {
    var label = g.node(v);
    if (Object.prototype.hasOwnProperty.call(visited, v)) {
      return label.rank;
    }
    visited[v] = true;
    var rank = min(
      map(g.outEdges(v), function(e) {
        return dfs(e.w) - g.edge(e).minlen;
      })
    );
    if (rank === Number.POSITIVE_INFINITY || // return value of _.map([]) for Lodash 3
    rank === void 0 || // return value of _.map([]) for Lodash 4
    rank === null) {
      rank = 0;
    }
    return label.rank = rank;
  }
  forEach(g.sources(), dfs);
}
function slack(g, e) {
  return g.node(e.w).rank - g.node(e.v).rank - g.edge(e).minlen;
}
export {
  longestPath,
  slack
};
//# sourceMappingURL=src-dagre-rank-util.js.map
