"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const filter = require("../lodash-es/filter.cjs");
const max = require("../lodash-es/max.cjs");
const map = require("../lodash-es/map.cjs");
const range = require("../lodash-es/range.cjs");
const sortBy = require("../lodash-es/sortBy.cjs");
const forEach = require("../lodash-es/forEach.cjs");
const has = require("../lodash-es/has.cjs");
function initOrder(g) {
  var visited = {};
  var simpleNodes = filter.default(g.nodes(), function(v) {
    return !g.children(v).length;
  });
  var maxRank = max.default(
    map.default(simpleNodes, function(v) {
      return g.node(v).rank;
    })
  );
  var layers = map.default(range.default(maxRank + 1), function() {
    return [];
  });
  function dfs(v) {
    if (has.default(visited, v)) return;
    visited[v] = true;
    var node = g.node(v);
    layers[node.rank].push(v);
    forEach.default(g.successors(v), dfs);
  }
  var orderedVs = sortBy.default(simpleNodes, function(v) {
    return g.node(v).rank;
  });
  forEach.default(orderedVs, dfs);
  return layers;
}
exports.initOrder = initOrder;
//# sourceMappingURL=src-dagre-order-init-order.cjs.map
