Пример #1
0
        public string Solve()
        {
            var graph           = GetDirectedGraphFromSccInput();
            var componentsSizes = new List <int>();

            var searcher            = new GraphSearch(InputMaxNodeNumber);
            var connectedComponents = searcher.KasarajuFindSccs(graph);

            foreach (var component in connectedComponents)
            {
                componentsSizes.Add(component.Count);
            }

            componentsSizes.Sort();
            componentsSizes.Reverse();

            var topFiveComponents = componentsSizes.Take(5).ToArray();

            return(string.Join(", ", topFiveComponents));
        }