✅✅Easy C++ | Well explained and commented | Without priority queue
Approach\n Describe your approach to solving the problem. \nInstead of using priority queue(max heap) to get the maximum value of adjacent nodes, we can simply 
# Approach\n<!-- Describe your approach to solving the problem. -->\nInstead of using priority queue(max heap) to get the maximum value of adjacent nodes, we can simply sort the graph that we are making.\n**Steps:**\n1. Create the graph.\n2. Sort the values of adj nodes.\n3. Initialize sum with the value of node.\n4. Compare with 0 to avoid taking all negative elements after sorting, till the no. of nodes taken is less than k.\n5. Store the maximum sum in a variable and return it.\n\n# Complexity\n- Time complexity: O(n^2*log(n))\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int maxStarSum(vector<int>& vals, vector<vector<int>>& edges, int k) {\n        int n=vals.size();\n        int maxi=INT_MIN;\n        vector<vector<int>> graph(n+1);\n\n        //creation of graph\n        for(auto it: edges){\n            graph[it[0]].push_back(vals[it[1]]); //storing the value of adj node in prev node\n            graph[it[1]].push_back(vals[it[0]]); \n        }\n\n        for(int i=0; i<n; i++){\n            sort(graph[i].begin(), graph[i].end(), greater<int>());\n            int sum=0;\n            sum=vals[i]; //the value of the node on which you are\n            //you need to consider the value of node as well\n\n            for(int j=0; j<k && j<graph[i].size(); j++){ //extra condition to avoid runtime error\n                sum+=max(0, graph[i][j]); //comparing with 0, while taking sum\n                //to avoid negative numbers in sum\n            }\n            \n            maxi=max(maxi, sum); //taking the maximum possible sum\n        }\n        return maxi;\n    }\n};\n```
['Graph', 'Sorting', 'C++']