Easy To Understand || Graphs || 🔥🔥🔥🔥
Code


# Code
```java []

class Solution {
    public int maxStarSum(int[] vals, int[][] edges, int k) {
        ArrayList<ArrayList<Integer>> adjList = new ArrayList<>();
        for (int i = 0; i < vals.length; i++) {
            adjList.add(new ArrayList<>());
        }

        int[] inDegree = new int[vals.length];
        for (int[] edge : edges) {
           adjList.get(edge[0]).add(vals[edge[1]]);
            adjList.get(edge[1]).add(vals[edge[0]]);
            inDegree[edge[0]]++;
            inDegree[edge[1]]++;
        }

        
        int max = Integer.MIN_VALUE;
        for (int i = 0; i < vals.length; i++) {
        ArrayList<Integer> neighbors = adjList.get(i);
        Collections.sort(neighbors, Collections.reverseOrder());
         int sum = vals[i];
         int n = Math.min(k, neighbors.size());
         for (int j = 0; j < n; j++) {
                if (neighbors.get(j) > 0) {
                    sum += neighbors.get(j);
                }
            }
            max = Math.max(sum, max);
        }
        

        return max;
    }
}

```
['Graph', 'Sorting', 'Java']