[Java] Priority queue with graph
Intuition\n Describe your first thoughts on how to solve this problem. \nConstruct to graph, then sum all star of neighbor nodes.\n\n# Approach\n Describe your 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nConstruct to graph, then sum all star of neighbor nodes.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nUse `PriorityQueue` to sort the star of neighbor nodes.\n\n# Complexity\n- Time complexity: $$O(N*logN)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(N)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n  public int maxStarSum(int[] vals, int[][] edges, int k) {\n    Map<Integer, Queue<Integer>> graph = new HashMap<>();\n    for (int[] edge : edges) {\n      graph.putIfAbsent(edge[0], new PriorityQueue<>());\n      if (vals[edge[1]] > 0) {\n        Queue<Integer> queue = graph.get(edge[0]);\n        queue.offer(vals[edge[1]]);\n        if (queue.size() > k) {\n          queue.poll();\n        }\n      }\n\n      graph.putIfAbsent(edge[1], new PriorityQueue<>());\n      if (vals[edge[0]] > 0) {\n        Queue<Integer> queue = graph.get(edge[1]);\n        queue.offer(vals[edge[0]]);\n        if (queue.size() > k) {\n          queue.poll();\n        }\n      }\n    }\n\n    int result = Integer.MIN_VALUE;\n    // for lack of edge case\n    for(int star: vals) {\n      result = Math.max(result, star);\n    }\n\n    for (Map.Entry<Integer, Queue<Integer>> entry : graph.entrySet()) {\n      int sum = vals[entry.getKey()];\n      for (int star : entry.getValue()) {\n        sum += star;\n      }\n\n      result = Math.max(result, sum);\n    }\n\n    return result;\n  }\n}\n\n```
['Heap (Priority Queue)', 'Java']