示例#1
0
        public MatrixIterativePageRank(int page_count, float damping_factor = 0.85f, MatrixGenerator generator = null)
        {
            mPageCount     = page_count;
            mDampingFactor = damping_factor;

            if (generator == null)
            {
                generator = (pcount) =>
                {
                    return(new SparseMatrix(pcount, page_count));
                };
            }
            mL = generator(page_count);
            mC = new SparseMatrix(page_count, page_count);
        }
示例#2
0
        static void Main(string[] args)
        {
            Program         p         = new Program();
            MatrixGenerator matrixGen = new MatrixGenerator();
            int             nodes     = 0;
            int             loop      = 0;
            List <string>   matrix    = new List <string>();

            Console.WriteLine("Enter the Number of WebPages");
            nodes = Convert.ToInt32(Console.ReadLine());
            matrixGen.createMatrix(nodes);

            Console.WriteLine("How many times to loop?");
            loop = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine("Enter the Adjacency Matrix with 1 -> PATH & 0 -> No PATH between two WebPages:");

            String integers;

            for (int i = 1; i <= nodes; i++)
            {
                integers = Console.ReadLine();

                for (int j = 1; j <= nodes; j++)
                {
                    List <int> cost = integers.Split().Select(x => int.Parse(x)).ToList();

                    p.path[i, j] = cost[j - 1];

                    if (j == i)
                    {
                        p.path[i, j] = 0;
                    }
                }
                matrix.Add(integers);
            }
            for (int c = 0; c < 10; c++)
            {
                Console.WriteLine();
            }
            Console.WriteLine("\tMatrix is:");
            foreach (var m in matrix)
            {
                Console.WriteLine("\t" + m.ToString() + " ");
            }
            p.calc(nodes, loop);
        }