This is the code for connected components-
Please Tell me where am i going wrong
@amanb25,you are passing visited as value so the changes won’t appear in visited map instead you will be making a copy , so you have to pass visited by reference or pointer in dfs_helper function ,
at line 20, change it to void dfs_helper(T source, map<T, bool>&visited){
1 Like