C++ || DFS EXPLAINED | stepwise commented
Explanation of DFS:  \nImagine standing at the root and going down to child nodes (traversing subtrees)\n1. Assign the current nodes the value of nums[current i
**Explanation of DFS:**  \nImagine standing at the root and going down to child nodes (traversing subtrees)\n1. Assign the current nodes the value of nums[current index] to temp[current index] (current index = node 0, 1, 2, 3... here)\n2. Traverse the adjacent nodes of current node. If the child node is not visited call the recursive DFS traversal for these nodes and add the values that they return to the current node value.\nIt means we are at root and we are traversing the children of tree (subtree) and add the values that they return while backtraversing to the root.\n\n3. If after adding DFS traversal values of any child we have `sum at root > target` (target = value of one component),\n we return 1e6 as it is the max sum of whole tree we can have (constraints : max node val = 50, max no. of nodes = 1e4)\n4. If after traversing all the child nodes we see that `sum at current root = target` \nwe can clip off this subtree as one component and return 0 to be added back to root of current root.\n5. Else if `sum at current root < target` \nwe return the value of current root to be added to sum of its root (current root contributing in making a component with its own root)\n\n**If it helps, please UPVOTE : )**\n```\nclass Solution {\npublic:\n    int dfs(int v, int target, vector<int> &temp, vector<int>& nums, vector<vector<int>>& adj)\n    {\n        temp[v] = nums[v];                             //step 1\n        \n        for(auto u: adj[v])                            //step 2\n        {\n            if(temp[u])                                //already visited \n                continue;\n            \n            temp[v] += dfs(u, target, temp, nums, adj);\n            \n            if(temp[v] > target)                       //step 3\n                return 1e6;                            \n        }\n        if(temp[v] == target)                          //step 4\n            return 0;\n        return temp[v];                                //step 5\n    }\n    \n    int componentValue(vector<int>& nums, vector<vector<int>>& edges) \n    {\n        int n = nums.size();\n        vector<vector<int>> adj(n);                    //adjacency list, making graph\n        for(auto e: edges)\n        {\n            adj[e[0]].push_back(e[1]);\n            adj[e[1]].push_back(e[0]);\n        }\n        \n        int sum = 0;                                   //sum of all nodes\n        for(auto i: nums)\n            sum += i;\n        \n        for(int i=n; i>1; i--)                         //components = i, edges to be removed = i-1, we see if we can divide the graph into more than 1 component\n        {\n            if(sum % i != 0)                           //not possible to divide graph into equal components\n                continue;\n            \n            vector<int> temp(n, 0);\n            if(dfs(0, sum/i, temp, nums, adj) == 0)    //0 = curr node, sum/i = target sum for each component\n                return i-1;\n        }\n        return 0;\n    }\n};\n```
['Depth-First Search', 'Graph', 'C', 'C++']