python fastest Solution
import math\nclass Solution(object):\n    def maxStarSum(self, vals, edges, k):\n        """\n        :type vals: List[int]\n        :type edges: List[List[int]
import math\nclass Solution(object):\n    def maxStarSum(self, vals, edges, k):\n        """\n        :type vals: List[int]\n        :type edges: List[List[int]]\n        :type k: int\n        :rtype: int\n        """\n    # using the dictionary of list we can solve very easily\n        dict1, max_val = defaultdict(list), -100000000\n\n        for i,j in edges:\n            # both nodes connected to each other thatswhy add in both places\n            dict1[i].append(j)\n            dict1[j].append(i)\n\n        for key,val in dict1.items():\n            total = vals[key]\n            result = sorted([vals[i] for i in val])[::-1][:k]\n\n            for i in result:\n                if i > 0:\n                    total += i \n                else:\n                    break \n\n            max_val = max(max_val,total)\n\n        return max(max_val,max(vals))
[]