code: function extractMin(){
        var min = Infinity;
        var minNode;
        Object.keys(q).forEach(function(node){
          if (d[node] < min) {
            min = d[node];
            minNode = node;
          }
        });
        if (minNode === undefined) {
          // If we reach here, there's a disconnected subgraph, and we're done.
          q = {};
          return null;
        }
        delete q[minNode];
        return minNode;
      }
docs: Linear search to extract (find and remove) min from q.