code: function initRank(g) {
      var pq = new dig_data_PriorityQueue();
      g.nodes().forEach(function(u) {
        pq.add(u, g.indegree(u));
      });
  
      var current = [];
      var rankNum = 0;
      while (pq.size() > 0) {
        for (var min = pq.min(); pq.priority(min) === 0; min = pq.min()) {
          pq.removeMin();
          g.node(min).rank = rankNum;
          current.push(min);
        }
  
        if (current.length === 0) {
          throw new Error("Input graph is not acyclic!");
        }
  
        current.forEach(function(u) {
          g.successors(u).forEach(function(v) {
            pq.decrease(v, pq.priority(v) - 1);
          });
        });
  
        current = [];
        rankNum++;
      }
    }
docs: /*
  Finds a feasible ranking (description below) for the given graph and assigns
  a rank attribute to each node for that ranking.
  
  A feasible ranking is one such that for all edges e, length(e) >=
  min_length(e). For our purposes min_length(e) is always 1 and length(e)
  is defined as rank(v) - rank(u) for (u, v) = e.
  
  It is possible to improve the result of this function using either exact or
  iterative heuristic methods.