[C++] | Edge to Graph Conversion
\nclass Solution {\nprivate:\n    unordered_map<int, vector<int>> graph;\npublic:\n    int maxStarSum(vector<int>& vals, vector<vector<int>>& edges, int k) {\n 
```\nclass Solution {\nprivate:\n    unordered_map<int, vector<int>> graph;\npublic:\n    int maxStarSum(vector<int>& vals, vector<vector<int>>& edges, int k) {\n        int n = vals.size();\n        for (auto e : edges) {\n            graph[e[0]].push_back(e[1]);\n            graph[e[1]].push_back(e[0]);\n        }\n        int ans = *max_element(vals.begin(), vals.end());\n        for (auto [key, val] : graph) {\n            priority_queue<pair<int, int>> qt;\n            int res = vals[key];\n            ans = max(ans, res);\n            for (auto dest : val) {\n                qt.push({vals[dest], dest});\n            }\n            int size = min(k, (int)qt.size());\n            for (int i = 0; i < size; i++) {\n                res += vals[qt.top().second];\n                qt.pop();\n                ans = max(ans, res);\n            }\n        }\n        return ans;\n    }\n};\n```
['Graph', 'C', 'Interactive']