(cur, parent, depth, adjList, treeInfo, count)
| 38 | } |
| 39 | |
| 40 | function dfs(cur, parent, depth, adjList, treeInfo, count) { |
| 41 | let sum = 1; |
| 42 | |
| 43 | for (const child of adjList[cur]) { |
| 44 | if (child !== parent) { |
| 45 | sum += dfs(child, cur, depth + 1, adjList, treeInfo, count); |
| 46 | treeInfo.root += depth + 1; |
| 47 | } |
| 48 | } |
| 49 | count[cur] = sum; |
| 50 | return sum; |
| 51 | } |
| 52 | |
| 53 | function createAdjacencyList(n, edges) { |
| 54 | const list = {}; |
no outgoing calls
no test coverage detected