Skip to content

Instantly share code, notes, and snippets.

@CsengerG
Created December 23, 2015 11:43
Show Gist options
  • Select an option

  • Save CsengerG/0a387ded2203b85d3502 to your computer and use it in GitHub Desktop.

Select an option

Save CsengerG/0a387ded2203b85d3502 to your computer and use it in GitHub Desktop.
Count a number of components in a graph
int number_of_components = 0
for(int i=0;i<N;++i){
if(explored[i]==false){
dfs(i);
number_of_components++;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment