my sol
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```cpp []
class Solution {
public:
    int maxStarSum(vector<int>& vals, vector<vector<int>>& edges, int k) {
        if(edges.size() == 0){
            auto maxval = max_element(vals.begin(), vals.end());
            return *maxval;
        }
        int n = vals.size();
        vector<vector<int>> graph(n);

        for (const auto& edge : edges) {
        int u = edge[0];
        int v = edge[1];
        graph[u].push_back(vals[v]);
        graph[v].push_back(vals[u]);
    }
        long long ans = LLONG_MIN;
        for(int i = 0; i < graph.size(); i++){
            long long temp = 0;
            sort(graph[i].rbegin(), graph[i].rend());
            for(int j = 0; j < min(k, (int)graph[i].size()); j++){
                if(graph[i][j] > 0) temp += graph[i][j];
            }
            temp += vals[i];
            ans = max(temp, ans);
        }

        return ans;
    }
};
```
['C++']