const int mxN = 2e5;
int n, d[mxN], ans;
vector<int> adj[mxN];
void dfs(int u = 0, int p = -1) {
for (int v : adj[u]) {
if (v == p)
continue;
dfs(v, u);
ans = max(d[u] + d[v] + 1, ans);
d[u] = max(d[u], d[v] + 1);
}
}
ans gives the diameter of the tree .It is not that trivial to understand for me.can someone explain please explain how the code works