Python concise queue & heap solutions
Heap\n\nclass Solution:\n    def networkDelayTime(self, times, N, K):\n        q, t, adj = [(0, K)], {}, collections.defaultdict(list)\n        for u, v, w in t
* Heap\n```\nclass Solution:\n    def networkDelayTime(self, times, N, K):\n        q, t, adj = [(0, K)], {}, collections.defaultdict(list)\n        for u, v, w in times:\n            adj[u].append((v, w))\n        while q:\n            time, node = heapq.heappop(q)\n            if node not in t:\n                t[node] = time\n                for v, w in adj[node]:\n                    heapq.heappush(q, (time + w, v))\n        return max(t.values()) if len(t) == N else -1\n```\n* Queue\n```\nclass Solution:\n    def networkDelayTime(self, times, N, K):\n        t, graph, q = [0] + [float("inf")] * N, collections.defaultdict(list), collections.deque([(0, K)])\n        for u, v, w in times:\n            graph[u].append((v, w))\n        while q:\n            time, node = q.popleft()\n            if time < t[node]:\n                t[node] = time\n                for v, w in graph[node]:\n                    q.append((time + w, v))\n        mx = max(t)\n        return mx if mx < float("inf") else -1\n```
['Queue', 'Heap (Priority Queue)', 'Python']