Javascript Using Dijikstra Algorithm and Priority Queue (faster than 88.14% of js submissions)
Based on Dijikstra Algorithm (using Priority Queue). Finding distance from source node K\n\n\nclass QElement { \n    constructor(element, priority) \n    { \n  
Based on Dijikstra Algorithm (using Priority Queue). Finding distance from source node K\n\n```\nclass QElement { \n    constructor(element, priority) \n    { \n        this.element = element; \n        this.priority = priority; \n    } \n}\n\nclass PriorityQueue {\n    constructor() {\n        this.items = [];\n    }\n    enqueue(element, priority) {\n        var qElement = new QElement(element, priority); \n        var contain = false; \n        for (var i = 0; i < this.items.length; i++) {\n            if (this.items[i].priority > qElement.priority) {\n                this.items.splice(i, 0, qElement);\n                contain = true;\n                break;\n            }\n        }\n        if (!contain) {\n            this.items.push(qElement);\n        }\n    }\n    dequeue() {\n        if (this.isEmpty()) \n            return "Underflow"; \n        return this.items.shift(); \n    }\n    isEmpty() {\n        return this.items.length == 0;\n    }\n}\n    \n\nclass Graph {\n    constructor(N) {\n        this.num_vertices = N;\n        this.AdjList = new Map();\n    }\n    addVertex(v) {\n        this.AdjList.set(v, []);\n    }\n    addEdge(x, y, wt) {\n        this.AdjList.get(x).push({node: y, wt: wt}); \n    }\n};\n\n\nvar networkDelayTime = function(times, N, K) {\n    let graph = new Graph(N);\n    let distance = {};\n    let pq = new PriorityQueue();\n    for (var i = 1; i <= N; i++) {\n        graph.addVertex(i);\n        distance[i] = Infinity;\n    }\n    times.forEach(function(time){\n        graph.addEdge(time[0], time[1], time[2]);\n    });\n    distance[K] = 0;\n    pq.enqueue(K, 0);\n    while (!pq.isEmpty()) {\n        let minNode = pq.dequeue();\n        let currNode = minNode.element;\n        let weight = minNode.priority;\n        let adjVertexes = graph.AdjList.get(currNode);\n        adjVertexes.forEach(function(neigh){\n            let temp = distance[currNode] + neigh.wt;\n            if (temp < distance[neigh.node]) {\n                distance[neigh.node] = temp;\n                pq.enqueue(neigh.node, distance[neigh.node]);\n            }\n        })    \n    }\n    let time = 0;\n    Object.keys(distance).forEach(function(node) {\n       if (distance[node] > time) {\n           time = distance[node];\n       } \n    });\n    return time == Infinity ? -1 : time;\n};\n```
['Graph', 'Heap (Priority Queue)', 'JavaScript']