/*
Checks if the current ordering of the graph has a lower cross count than the
current best. If so, saves the ordering of the current nodes and the new
best cross count. This can be used with restoreBest to restore the last best
ordering.

If this is the first time running the function the current ordering will be
assumed as the best.

Returns `true` if this layout represents a new best.
function saveBest(g) {
  var graph = g.graph();
  var cc = crossCount(g);
  if (!('orderCC' in graph) || graph.orderCC > cc) {
    graph.orderCC = cc;
    graph.order = {};
    g.eachNode(function(u, value) {
      if ('order' in value) {
        graph.order[u] = value.order;
      }
    });
    return true;
  }
  return false;
}