docs: function betweennes(graph, oriented) {
    var Q = [],
      S = []; // Queue and Stack
    // list of predecessors on shortest paths from source
    var pred = Object.create(null);
    // distance from source
    var dist = Object.create(null);
    // number of shortest paths from source to key
    var sigma = Object.create(null);
    // dependency of source on key
    var delta = Object.create(null);
  
    var currentNode;
    var centrality = Object.create(null);
  
    graph.forEachNode(setCentralityToZero);
    graph.forEachNode(calculateCentrality);
  
    if (!oriented) {
      // The centrality scores need to be divided by two if the graph is not oriented,
      // since all shortest paths are considered twice
      Object.keys(centrality).forEach(divideByTwo);
    }
  
    return centrality;
  
    function divideByTwo(key) {
      centrality[key] /= 2;
    }
  
    function setCentralityToZero(node) {
      centrality[node.id] = 0;
    }
  
    function calculateCentrality(node) {
      currentNode = node.id;
      singleSourceShortestPath(currentNode);
      accumulate();
    }
  
    function accumulate() {
      graph.forEachNode(setDeltaToZero);
      while (S.length) {
        var w = S.pop();
        var coeff = (1 + delta[w])/sigma[w];
        var predecessors = pred[w];
        for (var idx = 0; idx < predecessors.length; ++idx) {
          var v = predecessors[idx];
          delta[v] += sigma[v] * coeff;
        }
        if (w !== currentNode) {
          centrality[w] += delta[w];
        }
      }
    }
  
    function setDeltaToZero(node) {
      delta[node.id] = 0;
    }
  
    function singleSourceShortestPath(source) {
      graph.forEachNode(initNode);
      dist[source] = 0;
      sigma[source] = 1;
      Q.push(source);
  
      while (Q.length) {
        var v = Q.shift();
        S.push(v);
        graph.forEachLinkedNode(v, toId, oriented);
      }
  
      function toId(otherNode) {
        // NOTE: This code will also consider multi-edges, which are often
        // ignored by popular software (Gephi/NetworkX). Depending on your use
        // case this may not be desired and deduping needs to be performed. To
        // save memory I'm not deduping here...
        processNode(otherNode.id);
      }
  
      function initNode(node) {
        var nodeId = node.id;
        pred[nodeId] = []; // empty list
        dist[nodeId] = -1;
        sigma[nodeId] = 0;
      }
  
      function processNode(w) {
        // path discovery
        if (dist[w] === -1) {
          // Node w is found for the first time
          dist[w] = dist[v] + 1;
          Q.push(w);
        }
        // path counting
        if (dist[w] === dist[v] + 1) {
          // edge (v, w) on a shortest path
          sigma[w] += sigma[v];
          pred[w].push(v);
        }
      }
    }
  }