c++
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n\n\nclass Solution {\n    int solve(vector<vector<int>>& adj, vector<int>& vals, int src, int k) {\n        int wt = vals[src];\n        priority_queue<int> maxHeap;\n\n        for (int neighbor : adj[src]) {\n            maxHeap.push(vals[neighbor]);\n        }\n\n        for (int i = 0; i < k && !maxHeap.empty(); i++) {\n            int topVal = maxHeap.top();\n            maxHeap.pop();\n            if (topVal > 0) {\n                wt += topVal;\n            }\n        }\n\n        return wt;\n    }\n\npublic:\n    int maxStarSum(vector<int>& vals, vector<vector<int>>& edges, int k) {\n        int n = vals.size();\n\n        if (n == 1) {\n            return vals[0];\n        }\n\n        vector<vector<int>> adj(n);\n\n        for (auto& it : edges) {\n            int u = it[0];\n            int v = it[1];\n\n            adj[u].push_back(v);\n            adj[v].push_back(u);\n        }\n\n        int ans = INT_MIN;\n\n        for (int i = 0; i < n; i++) {\n            ans = max(solve(adj, vals, i, k), ans);\n        }\n\n        return ans;\n    }\n};\n\n```
['C++']