Beispiel #1
0
        private void loadBaseSet(int[] resultDocs, int rootSize, int maxParents, int maxChildren)
        {
            //make rootset
            int[] rootSet = new int[Math.Min(resultDocs.Length, rootSize)];
            for (int i = 0; i < rootSet.Length; i++)
            {
                rootSet[i] = resultDocs[i];
            }

            //make baseset
            int[] parents;
            int[] children;
            for (int i = 0; i < rootSet.Length; i++)
            {
                pageGraph.AddPage(rootSet[i]);

                parents = index.GetInboundLinks(rootSet[i]);
                if (parents != null)
                {
                    maxParents = Math.Min(maxParents, parents.Length);
                    for (int j = 0; j < maxParents; j++)
                    {
                        pageGraph.AddPage(parents[j]);
                    }
                }
                children = index.GetOutboundLinks(rootSet[i]);
                if (children != null)
                {
                    maxChildren = Math.Min(maxChildren, children.Length);
                    for (int j = 0; j < maxChildren; j++)
                    {
                        pageGraph.AddPage(children[j]);
                    }
                }
            }
        }
Beispiel #2
0
        private void init()
        {
            DataTable docIds   = new d.DocData().GetIds();
            int       doccount = docIds.Rows.Count;
            float     initRank = 1f / doccount;
            LinkIndex index    = new LinkIndex();

            inboundLinks = new Hashtable();
            ranks        = new float[doccount];
            ids          = new int[doccount];

            int i = 0;
            int docid;

            int[] inboundArray;
            foreach (DataRow dr in docIds.Rows)
            {
                docid = Convert.ToInt32(dr[0]);

                ranks[i] = initRank;                    //load initial pagerank value
                ids[i]   = docid;                       //load docid into position i
                i++;

                Hashtable currInbounds = new Hashtable();                       //make hashtable for current docid
                inboundLinks.Add(docid, currInbounds);                          //store this hashtable of inboundlinks for current docid
                inboundArray = index.GetInboundLinks(docid);                    //get inbound links array for current docid
                foreach (int fromid in inboundArray)                            //store it in this hashtable
                {
                    currInbounds.Add(fromid, true);
                }
            }

            outboundLinkCouns = new Hashtable();
            DataTable linkCounts = new d.DocData().GetLinkCounts();
            int       countTo;

            foreach (DataRow dr in linkCounts.Rows)
            {
                docid   = Convert.ToInt32(dr[0]);
                countTo = Convert.ToInt32(dr[2]);
                outboundLinkCouns.Add(docid, countTo);
            }
        }