using System;
using System.Collections.Generic;
public class Solution {
static List[] list;
static int[] dist;
static int max = 0;
public int solution(int n, int[,] edge) {
//int answer = 0;
list = new List[n];
for (int i = 0; i < n; i++) list[i] = new List();
for (int i = 0; i < edge.Length / 2; i++)
{
list[edge[i,0] - 1].Add(edge[i,1] - 1);
list[edge[i,1] - 1].Add(edge[i,0] - 1);
}
dist = new int[n];
for (int i = 0; i < n; i++)
dist[i] = -1;
//Arrays.fill(dist, 9999);
//int[] array = new int[5] { 1, 2, 3, 4, 5 };
path(n);
int cnt = 0;
for (int i = 0; i < dist.Length; i++)
{
if (max == dist[i]) cnt++;
}
return cnt;
}
public static void path(int n)
{
Queue queue = new Queue();
queue.Enqueue(0);
dist[0] = 0;
while (queue.Count != 0) // while (queue.Count() != 0)
{
int vertex = queue.Dequeue();
//for (int i : list[vertex])
//for (int i=0; i < vertex;i++)
List stringList1 = new List(new string[] { "99", "182", "15" });
List intList1 = stringList1.ConvertAll(Convert.ToInt32);
string a= intList1[0].ToString();
foreach (int i in list[vertex])
{
if (dist[i] == -1)
{
dist[i] = dist[vertex] + 1;
max = Math.Max(max, dist[i]);
queue.Enqueue(i);
}
}
}
}
}