✅ Simple Python Solution - Sort reverse
Intuition\nGet a list of all the neighbours, then sort them in descending order\n\n\n# Code\n\nclass Solution:\n    def maxStarSum(self, vals: List[int], edges:
# Intuition\nGet a list of all the neighbours, then sort them in descending order\n\n\n# Code\n```\nclass Solution:\n    def maxStarSum(self, vals: List[int], edges: List[List[int]], k: int) -> int:\n        graph = defaultdict(list)\n        for start, end in edges:\n            if vals[end] > 0:\n                graph[start].append(vals[end])\n            if vals[start] > 0:\n                graph[end].append(vals[start])\n        \n        max_sum = -float(\'inf\')\n        for i in range(len(vals)):\n            total = 0\n            graph[i].sort(reverse=True)\n            max_sum = max(max_sum, vals[i] + sum(graph[i][:min(len(graph[i]), k)]))\n            \n        return max_sum\n```
['Python3']