示例#1
0
        private void loadLinks()
        {
            Hashtable docs = pageGraph.BaseSet;

            short docId;

            short[] links;
            IDictionaryEnumerator en = docs.GetEnumerator();

            while (en.MoveNext())
            {
                docId = Convert.ToInt16(en.Key);
                links = index.GetDocLinks(docId);
                if (links != null)
                {
                    foreach (short linkId in links)
                    {
                        if (docs.Contains(linkId))
                        {
                            pageGraph.AddLink(docId, linkId);
                        }
                    }
                }

                links = index.GetDocCitations(docId);
                if (links != null)
                {
                    foreach (short linkId in links)
                    {
                        if (docs.Contains(linkId))
                        {
                            pageGraph.AddLink(linkId, docId);
                        }
                    }
                }
            }
        }
示例#2
0
        public void TestAuthoritiesAndHubs()
        {
            d.AHPageGraph g = new d.AHPageGraph(5);
            g.AddPage(0);
            g.AddPage(1);
            g.AddPage(2);
            g.AddPage(3);
            g.AddPage(4);
            g.AddLink(0, 4);
            g.AddLink(0, 3);
            g.AddLink(1, 4);
            g.AddLink(2, 4);
            g.AddLink(2, 3);
            g.AddLink(4, 0);

            d.AHDocument[] authorities = g.GetAuthorities();
            d.AHDocument[] hubs        = g.GetHubs();

            Assert.AreEqual(5, g.BaseSetSize);

            Assert.AreEqual(5, authorities.Length);

            Assert.AreEqual(5, hubs.Length);

            Console.WriteLine("a:");
            foreach (d.AHDocument d in authorities)
            {
                Console.WriteLine(d.ToString());
            }

            Console.WriteLine("h:");
            foreach (d.AHDocument d in hubs)
            {
                Console.WriteLine(d.ToString());
            }
        }