public static void TwoTeams() { var n = Convert.ToInt32(Console.ReadLine()); visited = new bool[n]; used = new int[n]; for (int i = 0; i < n; i++) { var members = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x) - 1).ToList(); members.Remove(members.Last()); AdjacencyList.Add(members); } for (int i = 0; i < n; i++) { if (!visited[i]) { BFS(i); } } var teamFirst = new List <int>(); for (int i = 0; i < used.Length; i++) { if (used[i] % 2 == 0) { teamFirst.Add(i + 1); } } Console.WriteLine(teamFirst.Count); Console.WriteLine(String.Join(" ", teamFirst)); }
public GraphNode <T> AddNode(T value) { GraphNode <T> node = new GraphNode <T>(value); AdjacencyList.Add(node, new List <Edge <T> >()); _size++; return(node); }
public void AddVertex(Person obj) { Vertices.Add(obj); AdjacencyList.Add(new List <int>()); }