Python
Code


# Code
```python3 []
class Solution:
    def maxStarSum(self, vals: List[int], edges: List[List[int]], k: int) -> int:
        adj_list = [[] for _ in range(len(vals))]

        for u, v in edges:
            adj_list[u].append(-vals[v])  # Use negative values for max-heap
            adj_list[v].append(-vals[u])

        # Heapify each neighbor list
        for sublist in adj_list:
            heapq.heapify(sublist)

        # Compute the maximum star sum
        max_sum = float("-inf")
        for i, li in enumerate(adj_list):
            temp_sum=vals[i]
            
            for _ in range(k): 
                if li:
                    temp=heapq.heappop(li)  # Retrieve original value
                    if temp>=0:
                        break
                    temp_sum-=temp
                else:
                    break
            max_sum = max(temp_sum, max_sum)

        return max_sum if max_sum !=float("-inf") else 0
        

        
        
```
['Python3']