Map - Java 
IntuitionBuild a map of node -> top k connected nodeApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nBuild a map of `node -> top k connected node`\n\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```java []\nclass Solution {\n    public int maxStarSum(int[] vals, int[][] edges, int k) {\n        // build a map of node->top k edges\n        Map<Integer, PriorityQueue<Integer>> map = new HashMap<>();\n        for (int[] edge : edges) {\n            map.putIfAbsent(edge[0], new PriorityQueue<>());\n            map.putIfAbsent(edge[1], new PriorityQueue<>());\n            PriorityQueue pq1 = map.get(edge[0]), pq2 = map.get(edge[1]);\n            int val1 = vals[edge[1]], val2 = vals[edge[0]];\n            if (val1 > 0)\n                pq1.add(val1);\n            if (pq1.size() > k)\n                pq1.poll();\n            if (val2 > 0)\n                pq2.add(val2);\n            if (pq2.size() > k)\n                pq2.poll();\n        }\n        //System.out.println(map);\n        int res = -10000;\n        for (int i = 0; i < vals.length; i++) {\n            int sum = vals[i];\n            for (int vEdge : map.getOrDefault(i, new PriorityQueue<>()))\n                sum += vEdge;\n            //System.out.println(i + "|" + sum + "|" + res);\n            res = Math.max(res, sum);\n        }\n        return res;\n    }\n}\n```
['Java']