SIMPLE APPROACH
\n\n# Code\ncpp []\nclass Solution {\npublic:\n    int maxStarSum(vector<int>& vals, vector<vector<int>>& edges, int k) {\n        vector<vector<int>> adj(vals.
\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    int maxStarSum(vector<int>& vals, vector<vector<int>>& edges, int k) {\n        vector<vector<int>> adj(vals.size());\n        for(auto i:edges){\n            adj[i[0]].push_back(vals[i[1]]);\n            adj[i[1]].push_back(vals[i[0]]);\n        }\n        int kk=0;\n        for(auto i:adj){\n            vector<int> it=i;\n            sort(it.begin(),it.end());\n            reverse(it.begin(),it.end());\n            adj[kk]=it;\n            kk++;\n        }\n        int mx=INT_MIN;\n        for(int i=0;i<vals.size();i++){\n            int sum=vals[i];\n            mx=max(mx,sum);\n            for(int j=0;j<k && j<adj[i].size();j++){\n                sum+=adj[i][j];\n                mx=max(mx,sum);\n            }\n        }\n        return mx;\n    }\n};\n```
['C++']