distributor.distribute = function()

in src/core/distributor.js [150:174]


  distributor.distribute = function(nodes){
    if(!nodes || nodes.length===0) return [];

    if(options.algorithm=='none' || !helper.isDefined(options.algorithm)){
      return [nodes];
    }

    if(!distributor.needToSplit(nodes)){
      return [nodes];
    }

    const sortedNodes = nodes.concat().sort(function(a,b){
      return a.idealPos - b.idealPos;
    });

    if(typeof options.algorithm == 'function'){
      return options.algorithm(sortedNodes, options);
    }
    else if(algorithms.hasOwnProperty(options.algorithm)){
      return algorithms[options.algorithm](sortedNodes);
    }
    else{
      throw 'Unknown algorithm: ' + options.algorithm;
    }
  };