function layerComponents()

in app/assets/javascripts/sankey.js [390:417]


    function layerComponents() {
      var remainingComponents = components,
          nextComponents,
          visitedIndex,
          x = 0;

      while (remainingComponents.length) {
        nextComponents = [];
        visitedIndex = {};

        remainingComponents.forEach(function(component) {
          component.x = x;

          component.scc.forEach(function(n) {
            n.sourceLinks.forEach(function(l) {
              if (!visitedIndex.hasOwnProperty(l.target.component) &&
                   l.target.component != component.index) {
                nextComponents.push(components[l.target.component]);
                visitedIndex[l.target.component] = true;
              }
            })
          });
        });

        remainingComponents = nextComponents;
        ++x;
      }
    }