code: function init(g) {
      // We currently use DFS as described in the graphviz paper.
      var ordering = [];
      var visited = {};
  
      function dfs(u) {
        if (u in visited) {
          return;
        }
        visited[u] = true;
  
        var rankNum = g.node(u).rank;
        if (!(rankNum in ordering)) {
          ordering[rankNum] = [];
        }
        ordering[rankNum].push(u);
  
        g.neighbors(u, "both").forEach(function(v) {
          dfs(v);
        });
      }
  
      g.nodes().forEach(function(u) {
        if (g.node(u).rank === 0) {
          dfs(u);
        }
      });
  
      return ordering;
    }
docs: /*
  Returns an array of ranks where each rank has an array of nodes in the given
  rank. This initial pass attempts to generate a good starting point from
  which to generate an ordering with minimal edge crossings, but almost
  certainly some iteration will reduce edge crossing.