public static void ReadTree() { var nodeCount = int.Parse(Console.ReadLine()); for (int i = 0; i < nodeCount - 1; i++) { var edge = Console.ReadLine() .Trim() .Split(" ", StringSplitOptions.RemoveEmptyEntries) .Select(int.Parse) .ToList(); treeService.AddEdge(edge[0], edge[1]); } }