Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            //IPrinter printer = new ConsolePrinter();
            IPrinter printer = new TextFilePrinter($"percolations{DateTime.UtcNow:yyyyMMddHHmmss}.txt");

            //var union = new WeightedQuickUnionUFWrapper(50, printer);

            //union.open(0, 0);
            //union.open(1, 0);
            //union.open(2, 0);
            //union.open(3, 0);
            //union.open(4, 0);
            //union.open(5, 0);
            //union.open(6, 0);

            //union.open(6, 1);
            //union.open(7, 1);
            //union.open(8, 1);

            //union.open(8, 0);
            //union.open(9, 0);

            //union.StartSimulation();

            var results = WeightedQuickUnionUFWrapper.Simulate(1, 500, printer);

            var openedSitesCountAvg = results.Average(sr => sr.OpenedSitesCount);

            Console.ReadKey();
        }
Ejemplo n.º 2
0
        public static ICollection <SimulationResults> Simulate(int times, int n, IPrinter printer = null)
        {
            var results = new List <SimulationResults>();

            for (int i = 0; i < times; i++)
            {
                var wrapper = new WeightedQuickUnionUFWrapper(n, printer);

                wrapper.StartSimulation();

                results.Add(wrapper.ProvideResults());
            }

            return(results);
        }
Ejemplo n.º 3
0
 public void SetAlgorithm(WeightedQuickUnionUFWrapper algo)
 {
     _algo = algo;
 }