Count number of nodes in each connected part of an undirected unweighted graph
JavaScript
void DFS(int start, vector<int> v[],vector<int> &visited, int &count)
{
visited[start] = 1;
count++;
for(int i= 0; i<v[start].size(); ++i)
{
if(visited[v[start][i]] == 0)
DFS(v[start][i], v, visited);
}
}
---------------------------------------------------
for(int i=1;i<=n;++i)
{
if(visited[i] == 0 )
{
connected++;
int count=0;
DFS(i,v,visited,count);
cout<<"This component has "<<count<<" nodes"<<"\n";
}
}
Also in JavaScript:
- Title
- angular clone array without reference
- Category
- JavaScript
- Title
- how to get the timestamp in javascript
- Category
- JavaScript
- Title
- cdn react
- Category
- JavaScript
- Title
- convert negative number to positive in javascript
- Category
- JavaScript
- Title
- array matching
- Category
- JavaScript
- Title
- compare string camelcase and lowercase javascript
- Category
- JavaScript
- Title
- include javascript jquery file in html
- Category
- JavaScript
- Title
- how to load localt ext file in js
- Category
- JavaScript
- Title
- click on a radio button using jquery
- Category
- JavaScript
- Title
- copy one array to another javascript
- Category
- JavaScript
- Title
- how to use the map method in javascript
- Category
- JavaScript
- Title
- how to make a inventory in js
- Category
- JavaScript
- Title
- devexpress custom column field
- Category
- JavaScript
- Title
- javascript access pushed element
- Category
- JavaScript
- Title
- form taglib in jsp
- Category
- JavaScript
- Title
- array.splice javascript
- Category
- JavaScript
- Title
- how to make an async function
- Category
- JavaScript
- Title
- jason rpc reactjs
- Category
- JavaScript
- Title
- factorial javascript
- Category
- JavaScript
- Title
- how to get the size of the window in javascript
- Category
- JavaScript
- Title
- how to remove element from array in javascript
- Category
- JavaScript
- Title
- how to gather true or false value from html checkbox in javascript
- Category
- JavaScript
- Title
- dynamic for loop react
- Category
- JavaScript
- Title
- how to change a string to number in javascript
- Category
- JavaScript
- Title
- is var is not blank then display value in javascript
- Category
- JavaScript
- Title
- add cloudinary to gatsby javascript
- Category
- JavaScript
- Title
- javascript audio stop
- Category
- JavaScript
- Title
- Javascript compare two arrays
- Category
- JavaScript
- Title
- array methods in javascript
- Category
- JavaScript
- Title
- add dev dependency yarn
- Category
- JavaScript
- Title
- console trace js
- Category
- JavaScript
- Title
- can you do a join() in js without the commas
- Category
- JavaScript
- Title
- how to add ' in javascript string
- Category
- JavaScript
- Title
- concat js mdn
- Category
- JavaScript
- Title
- conditional jsx property
- Category
- JavaScript
- Title
- javascript carousel
- Category
- JavaScript
- Title
- javascript break out of loop
- Category
- JavaScript
- Title
- click doesn't work on ajax loaded data
- Category
- JavaScript
- Title
- disregard empty field in array
- Category
- JavaScript
- Title
- how to get the index of an array in javascript
- Category
- JavaScript
- Title
- button style not working react native
- Category
- JavaScript
- Title
- angularjs left xx characters
- Category
- JavaScript
- Title
- how to check version of node js in cmd
- Category
- JavaScript
- Title
- casl react
- Category
- JavaScript
- Title
- how to create a list in javascript
- Category
- JavaScript
- Title
- check first two number jquery
- Category
- JavaScript
- Title
- get client timezone offset in JavaScript
- Category
- JavaScript
- Title
- how to play sound on load js
- Category
- JavaScript
- Title
- angular subscribe
- Category
- JavaScript
- Title
- express() vs express.router()
- Category
- JavaScript
- Title
- how to implement cland format into js file
- Category
- JavaScript
- Title
- javascript add option element to select
- Category
- JavaScript
- Title
- How to uninstall npm modules in node js?
- Category
- JavaScript
- Title
- javascript automatic click
- Category
- JavaScript
- Title
- html decode javascript
- Category
- JavaScript
- Title
- add new items in a select input using js
- Category
- JavaScript
- Title
- delete session javascript
- Category
- JavaScript
- Title
- how to refrence image in dart angular
- Category
- JavaScript
- Title
- alphabet array js
- Category
- JavaScript
- Title
- Django application with User and ActivityPeriod models, write a custom management command to populate the database with some dummy data, and design an API to serve that data in the json format given above.
- Category
- JavaScript
- Title
- how to trigger an event on reload js
- Category
- JavaScript
- Title
- AWS SDK for javascript assumerole with proxy
- Category
- JavaScript
- Title
- Add object to array javascript
- Category
- JavaScript
- Title
- disable mixed content via javascript
- Category
- JavaScript
- Title
- convert string true to boolean true javascript
- Category
- JavaScript
- Title
- gulp-download-stream
- Category
- JavaScript
- Title
- convert this to d3.select()
- Category
- JavaScript
- Title
- how to make item not dragable in react-sortablejs
- Category
- JavaScript
- Title
- iso to date javascript
- Category
- JavaScript
- Title
- angular email validation
- Category
- JavaScript
- Title
- how to make a javascript game
- Category
- JavaScript
- Title
- console log larger
- Category
- JavaScript
- Title
- Factorial
- Category
- JavaScript
- Title
- devextreme custom field
- Category
- JavaScript
- Title
- export to logs to elasticsearch node from fluend container k8s
- Category
- JavaScript
- Title
- chart.js reduce doughnut tickness
- Category
- JavaScript
- Title
- get url of page in background script
- Category
- JavaScript
- Title
- count value a to b character javascript
- Category
- JavaScript
- Title
- function js
- Category
- JavaScript
- Title
- how to send get request to external server using node
- Category
- JavaScript
- Title
- get date one week from now javascript
- Category
- JavaScript
- Title
- angular stacked bar
- Category
- JavaScript
- Title
- fetch api based on id nodejs and mongodb
- Category
- JavaScript
- Title
- angular ngclass
- Category
- JavaScript
- Title
- javascript check if function exists
- Category
- JavaScript
- Title
- firestore update map
- Category
- JavaScript
- Title
- angular generate component
- Category
- JavaScript
- Title
- check if variable is undefined or null jquery
- Category
- JavaScript
- Title
- check a checkbox jquery
- Category
- JavaScript
- Title
- get day js
- Category
- JavaScript
- Title
- ajax open a request
- Category
- JavaScript
- Title
- how do you remove a remove element from array in javascript
- Category
- JavaScript
- Title
- codemirror get object from textarea
- Category
- JavaScript
- Title
- delegate jquery
- Category
- JavaScript
- Title
- date add hours javascript
- Category
- JavaScript
- Title
- document ready
- Category
- JavaScript
- Title
- express js list all routes
- Category
- JavaScript
- Title
- get all keys in json object
- Category
- JavaScript
- Title
- electron scrollbar
- Category
- JavaScript
- Title
- create bottom navigation bar react native
- Category
- JavaScript