code: function crossCount(g, layering) {
    var cc = 0;
    for (var i = 1; i < layering.length; ++i) {
      cc += twoLayerCrossCount(g, layering[i-1], layering[i]);
    }
    return cc;
  }
docs: /*
  A function that takes a layering (an array of layers, each with an array of
  ordererd nodes) and a graph and returns a weighted crossing count.
  
  Pre-conditions:
  
  1. Input graph must be simple (not a multigraph), directed, and include
  only simple edges.
  2. Edges in the input graph must have assigned weights.
  
  Post-conditions:
  
  1. The graph and layering matrix are left unchanged.
  
  This algorithm is derived from Barth, et al., "Bilayer Cross Counting."