Ejemplo n.º 1
0
        private static void Traverse(Node[] start, bool[] visited, ref int cycles)
        {
            foreach (Node item in start)
            {
                visited = new bool[start.Length];
                visited[item.Id - 1] = true;
                foreach (Edge innerItem in item.Edges)
                {
                    if (!visited[innerItem.Destination.Id - 1])
                    {
                        currPopulity++;
                        visited[innerItem.Destination.Id - 1] = true;
                        foreach (Edge inner2 in innerItem.Destination.Edges)
                        {
                            if (!visited[inner2.Destination.Id - 1])
                            {
                                currPopulity++;
                                visited[inner2.Destination.Id - 1] = true;
                                break;
                            }
                        }  
                    }
                }

                if (currPopulity > bestPopularity)
                {
                    bestPopularity = currPopulity;
                    
                }
                currPopulity = 0;
            }
        }
Ejemplo n.º 2
0
        public static void Traverse(Node[] nodes)
        {

            bool[] visited = new bool[nodes.Length];
            int cycles = 0;
            //foreach (Node item in nodes)
            {
                Program.Traverse(nodes, visited, ref cycles);
            }
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            Node[] nodes = new Node[n];
            Node currNode = null;
            for (int i = 0; i < n; i++)
            {
                currNode = new Node(i + 1);
                currNode.Popularity = 1;
                nodes[i] = currNode;
            }

            for (int i = 0; i < n; i++)
            {
                string relativity = Console.ReadLine();

                for (int charSymbol = 0; charSymbol < relativity.Length; charSymbol++)
                {
                    if (relativity[charSymbol] == 'Y')
                    {
                        nodes[i].AddConnection(new Edge(nodes[charSymbol]));
                    }
                }
            }

            Program.Traverse(nodes);

            Console.WriteLine(bestPopularity);
        }
Ejemplo n.º 4
0
 public Edge(Node destination)
 {
     this.Destination = destination;
 }
Ejemplo n.º 5
0
 public void Add(Node node)
 {
     this.Nodes.Add(node);
 }