✅ [PYTHON] ✅ SIMPLE SOLUTION |
Code\n\nclass Solution:\n    def maxStarSum(self, v: List[int], edges: List[List[int]], k: int) -> int:\n        n = len(v)\n        g = defaultdict(list)\n    
# Code\n```\nclass Solution:\n    def maxStarSum(self, v: List[int], edges: List[List[int]], k: int) -> int:\n        n = len(v)\n        g = defaultdict(list)\n        for s,d in edges:\n            g[s].append([v[d],d])\n            g[d].append([v[s],s])\n        \n        ms = -inf\n        \n        for z in range(n):\n            if g[z]:\n                g[z].sort(reverse=True)\n\n                cs = v[z]\n                c = k\n                for j in range(len(g[z])):\n\n                    if g[z][j][0] > 0:\n                        cs += g[z][j][0]\n                        c = c-1\n\n                        if c == 0: break\n\n                    else: break\n                    \n                ms = max(ms,cs)\n                \n        \n        if ms == -inf:\n            return max(v)\n        else:\n            return ms\n```
['Python3']