These notes move from basic commands to more advanced command composition. The goal is to understand how simple commands combine to form powerful pipelines.
This code comes from this youtube channel The Complete Guide to WebSockets one of the best channel to learn Networking and Deep dive concepts of System Design etc.
const http = require("http");
const WebSocket = require("websocket").server;
let connection = null;We use Dijkstra algorithm to find the minimum distance from single srouce(src) to all other vertex in the given graph. It works only on Undirected Weighted Graph which are not having negative edge weights. It uses a greedy approach that repeatedly minimize the distances to other vertices.
We use priority queue to implement Dijkstra's algorithm.
The theory part you can learn on the Internet.
__dirname : This gives us the path from the OS to the folder in which you used it. (important is folder here because we used this command in some file that reside inside that folder)
FOR EXAMPLE: C:\Users\Lenovo\Desktop\Fun\routes\shop.js this is the path in which we used __dirname then we will going to get path upto
C:\Users\Lenovo\Desktop\Fun\routes\
__filename: This command when used gives the full path from OS to the file in which we used it.
So for above example we will get C:\Users\Lenovo\Desktop\Fun\routes\shop.js
Now we know that node js ships with it a core module that is path module.
ST(Spanning Tree) is a tree like subgraph of a connected, undirected graph that include all the vertices of the graph. In simple words, It is a tree like structure (hence no cycle) where the edges are the subset of graph and vertices are the exact set of original graph.
MST is excatly same like ST but with one more constraint of having minimum weight sum of edges.
| #include<bits/stdc++.h> | |
| using namespace std; | |
| void swap(vector<int>& nums, int i, int j) | |
| { | |
| int temp = nums[i]; | |
| nums[i] = nums[j]; | |
| nums[j] = temp; | |
| } |
| Run npm test | |
| > food-order-website@0.1.0 test | |
| > react-scripts test | |
| FAIL src/App.test.js | |
| ✕ renders learn react link (88 ms) | |
| ● renders learn react link |
| #include<bits/stdc++.h> | |
| using namespace std; | |
| class Graph | |
| { | |
| private: | |
| int n; | |
| vector<int> *list; | |
| public: |
| #include <bits/stdc++.h> | |
| using namespace std; | |
| // to detect cycle in undirected graph we will keep track of the parent node | |
| // if the nbr of a vertex is visited and not its parent that means cycle is present. | |
| // we have to keep track of parent because in undirected graph visited node can be its parent | |
| // which is not considered as back edge. | |
| class Graph | |
| { |