code: function path(){
        var nodeList = [];
        var weight = 0;
        var node = destination;
        while(p[node]){
          nodeList.push(node);
          weight += getEdgeWeight(p[node], node);
          node = p[node];
        }
        if (node !== source) {
          throw new Error("No path found");
        }
        nodeList.push(node);
        nodeList.reverse();
        nodeList.weight = weight;
        return nodeList;
      }
docs: Assembles the shortest path by traversing the predecessor subgraph from destination to source.