Python 3 || Greedy
Approach\n Describe your approach to solving the problem. \n    Taking the maximum of sum of k neighbours of each node\n# Complexity\n- Time complexity:\n Add y
# Approach\n<!-- Describe your approach to solving the problem. -->\n    Taking the maximum of sum of k neighbours of each node\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n    O(nlogn)\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n    O(n)\n\n# Code\n```\nclass Solution:\n    def maxStarSum(self, vals: List[int], edges: List[List[int]], k: int) -> int:\n        d=defaultdict(list)\n        for i in edges:\n            d[i[0]].append(vals[i[1]])\n            d[i[1]].append(vals[i[0]])\n        ans=-float(\'inf\')\n        if(not(d)):\n            return max(vals)\n        for i in d:\n            d[i].sort(reverse=True)\n        for i in range(len(vals)):\n            x=vals[i]\n            print\n            for j in range(min(len(d[i]),k)):\n                if(d[i][j]>=0):\n                    x+=d[i][j]\n            ans=max(ans,x)\n        return ans\n```
['Greedy', 'Graph', 'Python3']