C++ // DIJKSTRA // PRIORITY_QUEUE nothing more than that
\nclass Solution {\npublic:\n    int networkDelayTime(vector<vector<int>>& times, int N, int K) {\n      // nodes from 1 to N\n\t  vector<vector<pair<int,int>>>
```\nclass Solution {\npublic:\n    int networkDelayTime(vector<vector<int>>& times, int N, int K) {\n      // nodes from 1 to N\n\t  vector<vector<pair<int,int>>> graph(N+1);\n\t  // table is to store time it takes from node K \n      vector<int> table(N+1, INT_MAX);\n      // starts from K\n\t  table[K] = 0;\n      \n\t  // making graph\n      for (auto vec : times) {\n        int u = vec[0], v = vec[1], w = vec[2];\n        graph[u].push_back(make_pair(v, w));\n      }\n      \n\t  // maybe this question is checking us if we know the usage of priority queue\n\t  // the priority queue will sort(in not increasing order) based on time from K node \n      priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> pq;\n      pq.push(make_pair(0, K));\n      \n      while (!pq.empty()) {\n        int cur_dis = pq.top().first;\n        int cur_node = pq.top().second;\n        pq.pop();\n        \n        for (int i=0; i<graph[cur_node].size(); i++) {\n          int next_node = graph[cur_node][i].first;\n          int next_weight = graph[cur_node][i].second;\n          \n\t\t  // add node to priority queue whenever the time recorded is larger than currently computed time\n          if (table[next_node] > table[cur_node] + next_weight) {\n            table[next_node] = table[cur_node] + next_weight;\n            pq.push(make_pair(table[next_node], next_node));\n          }\n        }\n      }\n      \n      int result = 0;\n\t  // checking if there is unvisited node and the maximum result for our question\n      for (int i=1; i<=N; i++) {\n        if (table[i] == INT_MAX) return -1;\n        if (table[i] > result) result = table[i]; \n      }\n      \n      return result;\n    }\n};\n```
['C', 'Heap (Priority Queue)', 'C++']