Convert the edge list into an adjacency list to represent the tree as a graph.
Perform BFS starting from an arbitrary node (e.g., node 0) to find the farthest node from it. Keep track of the visited nodes and the distance from the starting node.
Perform BFS a second time starting from the farthest node found in step 2. Again, keep track of the visited nodes and the distance from the starting node.
The maximum distance found in the second BFS is the diameter of the tree.