func_code_string: #include <bits/stdc++.h>   using namespace std;   vector<int> g[100001];   int dist[100001];   int n, m;   void bfs(int x) {     queue<int> q;     int cur, i;     memset(dist, -1, sizeof(dist));     dist[x] = 0;     q.push(x);     while (!q.empty()) {       cur = q.front();       q.pop();       for (i = 0; i < (int)g[cur].size(); i++) {         if (dist[g[cur][i]] == -1) {           dist[g[cur][i]] = dist[cur] + 1;           q.push(g[cur][i]);         }       }     }   }   int main() {     int i, a, b, x, res;     scanf( %d%d , &n, &m);     for (i = 0; i < m; i++) {       scanf( %d%d , &a, &b);       g[a].push_back(b);       g[b].push_back(a);     }     bfs(1);     res = 0;     x = 1;     for (i = 1; i <= n; i++) {       if (dist[i] > res) {         res = dist[i];         x = i;       }     }     bfs(x);     res = 0;     for (i = 1; i <= n; i++) {       res = max(res, dist[i]);     }     printf( %d n , res);     return 0;   }   