No of Connected Components

PHOTO EMBED

Mon Jan 10 2022 06:50:46 GMT+0000 (Coordinated Universal Time)

Saved by @vaibhav_55

//Aplication of DFS traversal is to find if the graph is connected or not below is the implementation of it
          int no_of_connected_components = 0;
          for (int i = 1; i <= nodes; i++)
          {
              if (visited[i] == false)
              {
                  dfs(i);
                  no_of_connected_components++;
              }
          }
          //above dfs function is same as previous algo's dfs
content_copyCOPY