Form a graph and choose biggest edges
\nfrom collections import defaultdict\n\nclass Solution:\n    def maxStarSum(self, vals: List[int], edges: List[List[int]], k: int) -> int:\n        graph = def
```\nfrom collections import defaultdict\n\nclass Solution:\n    def maxStarSum(self, vals: List[int], edges: List[List[int]], k: int) -> int:\n        graph = defaultdict(list)\n        for i in range(len(vals)):\n            graph[i] = []\n        for a, b in edges:\n            graph[a].append((b, vals[b]))\n            graph[b].append((a, vals[a]))\n        res = float(\'-inf\')\n        for el in graph:\n            curr = vals[el]\n            nb = []\n            for j, c in graph[el]:\n                nb.append(c)\n            nb.sort(reverse = True)\n            for i in range(min(len(nb), k)):\n                curr += max(nb[i], 0)\n            res = max(res, curr)\n        return res\n```
['Python']