AI Generated Answers. The original questions generally came from this blog and are attributed to Sayed Ahmed. New AI-generated answers and examples are offered for reuse without copyright restrictions asserted by this site; linked third-party content retains its own terms. Validate results before applying them.
Course index · Original questions: HITS questions and related repost · This part answers 04.26–04.45.
Important convention: A[i,j] indicates an edge from page i to page j. Consequently, HITS updates hub scores with A and authority scores with Aᵀ. A PageRank transition matrix is row-stochastic and is a different object.
Q04.26. What are the three matrices that are used for HITS algorithm? i.e. when you want to implement HITS algorithm.
Answer. The usual implementation uses one adjacency matrix A and two score vectors h and a. Sometimes textbooks call all three ‘matrices’ by treating vectors as n×1 matrices. Derived products AAᵀ and AᵀA explain hub and authority eigenvectors.
Q04.27. What is a Transition Matrix in HITS?
Answer. In HITS, the relevant link matrix is commonly the adjacency matrix A, where A[i,j]=1 if i links to j. ‘Transition matrix’ usually refers to a row-stochastic probability matrix in PageRank; do not automatically use PageRank’s normalization for HITS.
Q04.28. What is a HUB vector? What does it contain initially?
Answer. The hub vector h ∈ R^n assigns a hub score to each vertex. A common initialization is all ones, later normalized. Any suitable positive starting vector is possible; scale is arbitrary before normalization.
Q04.29. What is an Authority vector? What does it contain initially?
Answer. The authority vector a ∈ R^n assigns one authority score per vertex. A common initialization is all ones, followed by updates from incoming hub scores and normalization.
Q04.30. For the graph below, provide the Initial Transition, Hub, Authority Vector/Matrices. Directed Graph {Source, Destination} Node: Yahoo, Amazon, Microsoft Edges: {Yahoo, Yahoo} {Yahoo, Amazon} {Yahoo, Microsoft} {Amazon, Yahoo} {Amazon, Microsoft} {Microsoft, Amazon}
Answer. For vertex order (Yahoo, Amazon, Microsoft), set A=[[1,1,1],[1,0,1],[0,1,0]]. The Yahoo→Yahoo self-loop explains A[0,0]=1. Initialize h⁽⁰⁾=a⁽⁰⁾=[1,1,1]ᵀ. Both initial scores can be normalized to L2 norm one.
Q04.31. For the same graph above, explain your transition matrix? If Transition Matrix is A, Hub Vector = h0, Authority Vector = a0.
Answer. Rows are link sources and columns are targets. Yahoo links to all three, Amazon to Yahoo and Microsoft, and Microsoft to Amazon. Thus the matrix row sums are 3,2,1. The diagonal entry for Yahoo is the self-link.
Q04.32. How is Hub Score for a page is updated?, How is Authority Score for a page is updated? How long does this update happen?
Answer. Using row-as-source A, update a←Aᵀh and h←Aa, normalizing each vector. For the supplied A and all-one initial vectors, the first raw updates are h=[3,2,1] and a=[2,2,2] if both are calculated from the old vectors. Iterate until a tolerance or maximum passes.
Q04.33. The algorithm/steps as mentioned above: will the update converge to a state where Hub and Authority values will no longer change? Why, why not? if convergence does not happen what to do?
Answer. Under suitable nonnegative spectral conditions, normalized HITS vectors converge to dominant eigenvector directions, but reducible graphs, tied leading eigenvalues, or periodicity and numerical details can produce ambiguity/instability. Use a maximum iteration count, convergence tolerance, component checks, and clear tie handling; singular-vector methods are an alternative.
Q04.34. What is HITS normalization? i.e. after each iteration. Why it might be important.
Answer. Without normalization, repeatedly multiplying by A and Aᵀ may make magnitudes explode or vanish, obscuring rankings. Rescale hub and authority vectors after each update (often to unit Euclidean norm) so their relative components can be compared.
Q04.35. Give steps/equations used for HITS normalization.
Answer. For a nonzero vector x, ‖x‖₂ = sqrt(Σ_i x_i²) and x_norm = x / ‖x‖₂. Apply to h_next=Aa and a_next=Aᵀh separately. If a vector is zero, define an explicit fallback or detect an empty-link case rather than dividing by zero.
Q04.36. What are the two ways, you can make the HITS algorithm stop? i.e. stopping points.
Answer. Stop when both vector changes fall below a tolerance, such as max(‖h_new−h‖₂,‖a_new−a‖₂)<ε, or after a fixed maximum number of iterations. More robust code combines both and reports if the tolerance was not reached.
Q04.37. True or False, Destiny of PageRank and HITS were different. What does it mean?
Answer. Historically their adoption differed: PageRank became a widely recognized web-ranking component, while HITS remained especially associated with topic-dependent hub/authority analysis and research. Neither alone describes how modern search ranking systems operate today.
Q04.38. Can you stop the HITS algorithm after a certain number of iterations?
Answer. Yes. A fixed number of passes is a valid computational stopping rule. Record the pass count and residual change; a premature stop may yield only an approximate ranking.
Q04.39. In real life, are HITS and PageRank used/applied for the whole graph i.e. whole Internet for example? Or majority of the times, they are applied on contextual graphs?
Answer. Not as a universal rule. HITS is often computed for a query/topic-specific base set; PageRank has historically been computed over large web graphs. Both can also be applied to a small, context-specific network such as citations within one field.
Q04.40. What are contextual graphs, anyway?
Answer. A contextual graph is a subgraph selected for a purpose, time window, topic, or community—for example, only pages on a university admissions topic or only transactions in the past 30 days. Selection choices influence the score.
Q04.41. Give example use cases for HITS and PageRank?
Answer. HITS: rank curated hubs and authoritative pages on a technical topic. PageRank: prioritize scholarly papers in a citation network or pages in a web crawl. In both cases, link spam, missing edges, and domain-specific meaning limit interpretation.
Q04.42. Can you think of the value aspect of these algorithms? i.e. how they affect people, communities, societies?
Answer. These scores influence which sources get attention, traffic, and visibility; feedback loops can advantage established nodes and marginalize smaller ones. Practical systems should test for manipulation, biases, accessibility, privacy harms, and whether link popularity is an appropriate proxy for quality.
Q04.43. What are the programming languages where you will find libraries that implement the HITS and PageRank algorithm? Give the name of the libraries.
Answer. Python: networkx.hits and networkx.pagerank; igraph has PageRank and hub/authority scoring in common bindings. R: igraph::page_rank, hub_score, authority_score. Check library versions and API documentation.
Q04.44. Implement the algorithms from scratch in Python or in R without using the libraries. What did you use to debug your implementation and how?
Answer. Implement using NumPy and the equations above; compare each result to an independently tested library on a small graph. See the complete compact reference implementation below. To debug, print matrices, check vector norms/sums, and examine convergence residuals each iteration.
Q04.45. What are the challenges that you faced to implement, how did you resolve? How did you represent the Graphs (i.e. on the graph you applied for testing).
Answer. Main implementation pitfalls: treating Aᵀ as A, failing to handle dangling PageRank nodes, forgetting teleportation, interpreting HITS self-links, mismatched node order, and expecting identical HITS/PageRank results. Use a fixed vertex order and tiny graphs with hand-computed updates; compare a baseline and inspect stopping residuals.
From-scratch Python: HITS and PageRank
import numpy as np
A = np.array([[1,1,1], [1,0,1], [0,1,0]], float)
n = A.shape[0]
def unit(x):
z = np.linalg.norm(x)
return x / z if z else x
def hits(A, steps=100, tol=1e-12):
n = len(A); h = unit(np.ones(n)); a = unit(np.ones(n))
for _ in range(steps):
a1 = unit(A.T @ h)
h1 = unit(A @ a1)
if max(np.linalg.norm(h1-h), np.linalg.norm(a1-a)) < tol:
return h1, a1
h, a = h1, a1
return h, a
def pagerank(A, alpha=0.85, steps=200, tol=1e-12):
n = len(A)
P = A.copy().astype(float)
for i in range(n):
degree = P[i].sum()
if degree: P[i] /= degree
else: P[i] = np.ones(n) / n # dangling page
r = np.ones(n)/n
for _ in range(steps):
rn = alpha * P.T @ r + (1-alpha)/n
if np.linalg.norm(rn-r, 1) < tol: return rn
r = rn
return r
h, a = hits(A)
print("hub:", np.round(h, 3))
print("authority:", np.round(a, 3))
print("PageRank:", np.round(pagerank(A), 3))
# Compare against networkx.hits and networkx.pagerank.
Debugging checklist: use a tiny known graph, inspect A and Aᵀ, verify nonnegative scores, check sum(PageRank)≈1 and ||hub||₂≈||authority||₂≈1, then compare rankings to NetworkX. Self-links are included in this historical example; real applications may remove them.
