faqts : Computers : Programming : Languages : Bbcbasic

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

Entry

BBCBASIC: Windows: Algorithm: Search: Google: Link: Pagerank: Can you show a simple program?

Jul 16th, 2006 14:58
Knud van Eeden,


----------------------------------------------------------------------
--- Knud van Eeden --- 16 July 2006 - 11:15 pm -----------------------

BBCBASIC: Windows: Algorithm: Search: Google: Link: Pagerank: Can you 
show a simple program?

===

Steps: Overview:

 1. -E.g. create the following program

--- cut here: begin --------------------------------------------------

 READ N%
 :
 IF N% <= 0 THEN PRINT "choose N% minimally 1" : STOP
 :
 DIM adjacencyMatrix$( N%, N% + 1 )
 :
 FOR I% = 1 TO N%
   FOR J% = 1 TO N% + 1
     READ adjacencyMatrix$( I%, J% )
   NEXT J%
 NEXT I%
 :
 DIM linkOutI%( N% )
 :
 FOR I% = 1 TO N%
   FOR J% = 2 TO N% + 1
     IF adjacencyMatrix$( I%, J% ) <> "" THEN
       linkOutI%( I% ) = linkOutI%( I% ) + 1
     ENDIF
   NEXT J%
 NEXT I%
 :
 FOR I% = 1 TO N%
   page$ = adjacencyMatrix$( I%, 1 )
   PRINT "page "; page$; ": ";
   PRINT; linkOutI%( I% ); " outgoing links"
 NEXT I%
 :
 DIM pageRankR( N% + 1 )
 :
 pageRankPageMaxR = 1 / N%
 :
 FOR columnI% = 2 TO N% + 1
   FOR rowI% = 1 TO N%
     linkOutI = linkOutI%( rowI% )

     IF ( ( adjacencyMatrix$( rowI%, columnI% ) <> "" ) AND ( linkOutI 
>= 1 ) ) THEN pageRankR( columnI% - 1 ) = pageRankR( columnI% - 1 ) + 
( pageRankPageMaxR * ( 1 / linkOutI ) )

   NEXT rowI%
 NEXT columnI%
 :
 PRINT
 :
 FOR I% = 1 TO N%
   page$ = adjacencyMatrix$( I%, 1 )
   PRINT "page "; page$; ": ";
   PRINT; pageRankR( I% ); " pagerank"
 NEXT I%
 :
 PRINT
 :
 REM now the demping factor
 dempingFactorR = 0.85
 :
 FOR I% = 1 TO N%
   page$ = adjacencyMatrix$( I%, 1 )
   PRINT "page "; page$; ": ";

   PRINT; ( 1 - dempingFactorR ) / N% + dempingFactorR * pageRankR( 
I% );

   PRINT; " pagerank with demping factor"
 NEXT I%
 :
 END
 :
 REM total pages (change this number to your total number of pages)
 DATA 4
 :
 REM page A links to no pages
 REM page B links to A and C
 REM page C links to A
 REM page D links to A, B and C
 :
 REM page, links to the following pages
 DATA "A", "" ,  "",  "",  ""
 DATA "B", "A",  "", "C",  ""
 DATA "C", "A",  "",  "",  ""
 DATA "D", "A", "B", "C",  ""
 :

 --- cut here: end ----------------------------------------------------

 2. -Run the program

 3. -That will show a screen output similar to the following:

--- cut here: begin --------------------------------------------------

 page A: 0 outgoing links
 page B: 2 outgoing links
 page C: 1 outgoing links
 page D: 3 outgoing links

 page A: 0.458333333 pagerank
 page B: 0.0833333334 pagerank
 page C: 0.208333333 pagerank
 page D: 0 pagerank

 page A: 0.427083333 pagerank with demping factor
 page B: 0.108333333 pagerank with demping factor
 page C: 0.214583333 pagerank with demping factor
 page D: 0.0375 pagerank with demping factor

--- cut here: end ----------------------------------------------------

 4. -If you want to test with the pages linking
     where B, C and D link all to page A
     replace the data with this

--- cut here: begin --------------------------------------------------

 REM page A links to no pages
 REM page B links to A
 REM page C links to A
 REM page D links to A
 :
 REM page, links to the following pages
 DATA "A", "" ,  "",  "",  ""
 DATA "B", "A",  "",  "",  ""
 DATA "C", "A",  "",  "",  ""
 DATA "D", "A",  "",  "",  ""
 :

--- cut here: end ----------------------------------------------------

 5. -That will show a screen output similar to the following:

--- cut here: begin --------------------------------------------------

 page A: 0 outgoing links
 page B: 1 outgoing links
 page C: 1 outgoing links
 page D: 1 outgoing links

 page A: 0.75 pagerank
 page B: 0 pagerank
 page C: 0 pagerank
 page D: 0 pagerank

 page A: 0.675 pagerank with demping factor
 page B: 0.0375 pagerank with demping factor
 page C: 0.0375 pagerank with demping factor
 page D: 0.0375 pagerank with demping factor

--- cut here: end ----------------------------------------------------

===

Internet: see also:

---

Internet: Search Engine: Google: Algorithm: Search: Link: Pagerank: 
Can you show a simple example?
http://www.faqts.com/knowledge_base/view.phtml/aid/41611/fid/828

----------------------------------------------------------------------