in out time of nodes
vector<vector<int>> adj; // adjacency list representation
int n; // number of nodes
int s; // source vertex
queue<int> q;
vector<bool> used(n);
vector<int> d(n), p(n);
q.push(s);
used[s] = true;
p[s] = -1;
while (!q.empty()) {
int v = q.front();
q.pop();
for (int u : adj[v]) {
if (!used[u]) {
used[u] = true;
q.push(u);
d[u] = d[v] + 1;
p[u] = v;
}
}
}
Also in JavaScript:
- sweet alert js
- json-server localhost
- csv export in react
- Robux gift
- position of the mouse cursor javascript
- javascript add div to body with class
- react native text-input-mask this.props.refInput
- how to reload page on button click in javascript
- how to get data in json format in javascript
- how to check if map is map javascript
- how to disable menu bar in browser using javascript
- jquery each has class
- javascript convert binary to text
- array index javascript show only first 2 elements
- trim whitespace javascript
- parsley validation checkbox alignment
- assign role on reaction by id discord.js
- button click function in js
- function to create an element javascript
- js loop over array of objects extract value
- javascript modify href attr
- javascript get scroll position
- javascript canvas reset transform
- how to get the value of radio button in jquery