Python - MinHeap
```\nclass Solution:\n    def maxStarSum(self, vals: List[int], edges: List[List[int]], k: int) -> int:\n        \n        m = defaultdict(list)                
```\nclass Solution:\n    def maxStarSum(self, vals: List[int], edges: List[List[int]], k: int) -> int:\n        \n        m = defaultdict(list)                   # For each node, we will have min heap of size k which stores values                                                             # of Top-K nodes it is connected to.\n        \n        for x,y in edges:       \n            \n            if vals[y]>0:                       # If neighbor value is negative, our star will have more value without it.\n                \n                heapq.heappush(m[x], vals[y])   # For each node, push this neighbors value to its heap\n                if len(m[x])>k:                 # If the Min-Heap size is more than K.                      \n                    heapq.heappop(m[x])         # Pop the smallest Neighbour value as we can\'t use it anyway.             \n            \n            if vals[x]>0:\n                heapq.heappush(m[y], vals[x])   # Repeat the same for other neighbor              \n                if len(m[y])>k:\n                    heapq.heappop(m[y])\n            \n            \n        res = -math.inf\n        for i in range(len(vals)):              # We\'ll try to maximize the star with each node being center\n            tot = vals[i]                       # Our total will be value of that node as it has to be included.\n            \n            for nei_value in m[i]:              # We will check each value in the heap for the node.                      \n                tot+=nei_value                  # We have already excluded neg values when pushing to Min-Heap\n                \n            res = max(res, tot)                 # We\'ll maximize our result\n            \n        return res                              \n        \n            \n            \n
['Heap (Priority Queue)', 'Python', 'Python3']