private double computeAverageFanOut ( Iterable < Page > pages ) { Set < Integer > pageIDs = new HashSet < Integer > ( ) ; while ( pages . iterator ( ) . hasNext ( ) ) { pageIDs . add ( pages . iterator ( ) . next ( ) . getPageId ( ) ) ; } if ( pageIDs . isEmpty ( ) ) { logger . warn ( "Cannot compute average fan-out of an empty page set." ) ; return 0.0 ; } int fanOutCounter = 0 ; Session session = this . wiki . __getHibernateSession ( ) ; session . beginTransaction ( ) ; Iterator results = session . createQuery ( "select page.outLinks, page.pageId from Page as page" ) . list ( ) . iterator ( ) ; while ( results . hasNext ( ) ) { Object [ ] row = ( Object [ ] ) results . next ( ) ; Set outLinks = ( Set ) row [ 0 ] ; Integer pageId = ( Integer ) row [ 1 ] ; // if the current page ID is in the desired result set => add outlink value if ( pageIDs . contains ( pageId ) ) { fanOutCounter += outLinks . size ( ) ; } } session . getTransaction ( ) . commit ( ) ; return ( double ) fanOutCounter / this . getNumberOfPages ( ) ; }
Computes the average fan out of the page set . Fan out is the number of outgoing links per page .