0% found this document useful (0 votes)
7 views3 pages

Exp 10 DWM

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views3 pages

Exp 10 DWM

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

EXPERIMENT NO.

10
Aim:- Implementation of HITS algorithm using Python

Theory:-
Hyperlink Induced Topic Search (HITS)
Hyperlink Induced Topic Search (HITS) Algorithm is a Link Analysis Algorithm that rates
webpages, developed by Jon Kleinberg. This algorithm is used to the web link-structures to
discover and rank the webpages relevant for a particular search.

HITS uses hubs and authorities to define a recursive relationship between webpages.
Before understanding the HITS Algorithm, we first need to know about Hubs and
Authorities.

● Given a query to a Search Engine, the set of highly relevant web pages are called Roots.
They are potential Authorities.

● Pages that are not very relevant but point to pages in the Root are called Hubs. Thus, an
Authority is a page that many hubs link to whereas a Hub is a page that links to many
authorities. Algorithm – -> Let number of iterations be k. -> Each node is assigned a Hub
score = 1 and an Authority score = 1. -> Repeat k times:

● Hub update : Each node’s Hub score = (Authority score of each node it points to).

● Authority update : Each node’s Authority score = (Hub score of each node pointing to it).

● Normalize the scores by dividing each Hub score by square root of the sum of the squares
of all Hub scores, and dividing each Authority score by square root of the sum of the squares
of all Authority scores. (optional) Now, let’s see how to implement this algorithm using
Networxx Module. Let us consider the following Graph

Python Code
import networkx as nx

import matplotlib.pyplot as plt

G = nx.DiGraph()

G.add_edges_from([('A', 'D'), ('B', 'C'), ('B', 'E'), ('C', 'A'),

('D', 'C'), ('E', 'D'), ('E', 'B'), ('E', 'F'),


('E', 'C'), ('F', 'C'), ('F', 'H'), ('G', 'A'),

('G', 'C'), ('H', 'A')])

nx.draw_networkx(G, with_labels = True)

plt.show()

hubs, authorities = nx.hits(G, max_iter = 50, normalized = True)

print("Hub Scores: ", hubs)

print("Authority Scores: ", authorities)

Output:-

Hub Scores: {'A': 0.04642540403219994, 'D': 0.13366037526115382, 'B': 0.15763599442967322,


'C': 0.03738913224642654, 'E': 0.25881445984686646, 'F': 0.1576359944296732, 'H':
0.03738913224642654, 'G': 0.17104950750758036}
Authority Scores: {'A': 0.10864044011724346, 'D': 0.13489685434358, 'B':
0.11437974073336447, 'C': 0.3883728003876181, 'E': 0.06966521184241478, 'F':
0.11437974073336447, 'H': 0.06966521184241475, 'G': 0.0}

You might also like