Best Solution || C++ || Priority Queue 
Complexity

Time complexity: O(Eloge+Vlogv)


Space complexity: O(V)

Code
# Complexity
- Time complexity: O(Eloge+Vlogv)


- Space complexity: O(V)
<!-- 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) {
        
        priority_queue<pair<int,pair<int,int>>> pq;

        for (int i=0; i<edges.size(); i++) {

            int node1 = edges[i][0];
            int node2 = edges[i][1];

            pq.push({vals[node2],{node1,node2}});
            pq.push({vals[node1],{node2,node1}});

        }

        vector<int> cnt(vals.size(),0);

        while (!pq.empty()) {
            
            int ad = pq.top().first;
            int n1 = pq.top().second.first;
            int n2 = pq.top().second.second;
            pq.pop();

            if (cnt[n1]<k && ad>0) {
                cnt[n1]++;
                vals[n1] += ad;
            }

        }

        int ans = *max_element(begin(vals),end(vals));

        return ans;

    }
};
```
['Heap (Priority Queue)', 'C++']