{"id":79112,"date":"2026-11-18T03:18:09","date_gmt":"2026-11-18T03:18:09","guid":{"rendered":"http:\/\/bangla.sitestree.com\/?p=79112"},"modified":"2026-11-18T03:18:09","modified_gmt":"2026-11-18T03:18:09","slug":"graph-mining-1-04-hits-pagerank-part-2","status":"publish","type":"post","link":"http:\/\/bangla.sitestree.com\/?p=79112","title":{"rendered":"Graph Mining &#8211; 1 | 04. HITS and PageRank \u2014 Part 2 (Q&#038;A)"},"content":{"rendered":"<p class=\"wp-block-paragraph\"><strong>AI Generated Answers.<\/strong> The original questions generally came from this blog and are attributed to <strong>Sayed Ahmed<\/strong>. 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.<\/p>\n<p class=\"wp-block-paragraph\"><a href=\"http:\/\/bangla.sitestree.com\/?p=79103\">Course index<\/a> \u00b7 Original questions: <a href=\"http:\/\/bangla.sitestree.com\/?p=16322\">HITS questions<\/a> and <a href=\"http:\/\/bangla.sitestree.com\/?p=22879\">related repost<\/a> \u00b7 This part answers 04.26\u201304.45.<\/p>\n<p class=\"wp-block-paragraph\"><strong>Important convention:<\/strong> A[i,j] indicates an edge from page i to page j. Consequently, HITS updates hub scores with A and authority scores with A\u1d40. A PageRank transition matrix is row-stochastic and is a different object.<\/p>\n<h3 class=\"wp-block-heading\">Q04.26. What are the three matrices that are used for HITS algorithm? i.e. when you want to implement HITS algorithm.<\/h3>\n<p class=\"wp-block-paragraph\"><strong>Answer.<\/strong> The usual implementation uses <strong>one adjacency matrix A<\/strong> and <strong>two score vectors h and a<\/strong>. Sometimes textbooks call all three \u2018matrices\u2019 by treating vectors as n\u00d71 matrices. Derived products <code>AA\u1d40<\/code> and <code>A\u1d40A<\/code> explain hub and authority eigenvectors.<\/p>\n<h3 class=\"wp-block-heading\">Q04.27. What is a Transition Matrix in HITS?<\/h3>\n<p class=\"wp-block-paragraph\"><strong>Answer.<\/strong> In HITS, the relevant link matrix is commonly the <strong>adjacency matrix<\/strong> A, where A[i,j]=1 if i links to j. \u2018Transition matrix\u2019 usually refers to a row-stochastic probability matrix in PageRank; do not automatically use PageRank\u2019s normalization for HITS.<\/p>\n<h3 class=\"wp-block-heading\">Q04.28. What is a HUB vector? What does it contain initially?<\/h3>\n<p class=\"wp-block-paragraph\"><strong>Answer.<\/strong> The hub vector <code>h \u2208 R^n<\/code> 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.<\/p>\n<h3 class=\"wp-block-heading\">Q04.29. What is an Authority vector? What does it contain initially?<\/h3>\n<p class=\"wp-block-paragraph\"><strong>Answer.<\/strong> The authority vector <code>a \u2208 R^n<\/code> assigns one authority score per vertex. A common initialization is all ones, followed by updates from incoming hub scores and normalization.<\/p>\n<h3 class=\"wp-block-heading\">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}<\/h3>\n<p class=\"wp-block-paragraph\"><strong>Answer.<\/strong> For vertex order (Yahoo, Amazon, Microsoft), set <code>A=[[1,1,1],[1,0,1],[0,1,0]]<\/code>. The Yahoo\u2192Yahoo self-loop explains A[0,0]=1. Initialize <code>h\u207d\u2070\u207e=a\u207d\u2070\u207e=[1,1,1]\u1d40<\/code>. Both initial scores can be normalized to L2 norm one.<\/p>\n<h3 class=\"wp-block-heading\">Q04.31. For the same graph above, explain your transition matrix? If Transition Matrix is A, Hub Vector = h0, Authority Vector = a0.<\/h3>\n<p class=\"wp-block-paragraph\"><strong>Answer.<\/strong> 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.<\/p>\n<h3 class=\"wp-block-heading\">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?<\/h3>\n<p class=\"wp-block-paragraph\"><strong>Answer.<\/strong> Using row-as-source A, update <code>a\u2190A\u1d40h<\/code> and <code>h\u2190Aa<\/code>, normalizing each vector. For the supplied A and all-one initial vectors, the first raw updates are <code>h=[3,2,1]<\/code> and <code>a=[2,2,2]<\/code> if both are calculated from the old vectors. Iterate until a tolerance or maximum passes.<\/p>\n<h3 class=\"wp-block-heading\">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?<\/h3>\n<p class=\"wp-block-paragraph\"><strong>Answer.<\/strong> 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.<\/p>\n<h3 class=\"wp-block-heading\">Q04.34. What is HITS normalization? i.e. after each iteration. Why it might be important.<\/h3>\n<p class=\"wp-block-paragraph\"><strong>Answer.<\/strong> Without normalization, repeatedly multiplying by A and A\u1d40 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.<\/p>\n<h3 class=\"wp-block-heading\">Q04.35. Give steps\/equations used for HITS normalization.<\/h3>\n<p class=\"wp-block-paragraph\"><strong>Answer.<\/strong> For a nonzero vector x, <code>\u2016x\u2016\u2082 = sqrt(\u03a3_i x_i\u00b2)<\/code> and <code>x_norm = x \/ \u2016x\u2016\u2082<\/code>. Apply to <code>h_next=Aa<\/code> and <code>a_next=A\u1d40h<\/code> separately. If a vector is zero, define an explicit fallback or detect an empty-link case rather than dividing by zero.<\/p>\n<h3 class=\"wp-block-heading\">Q04.36. What are the two ways, you can make the HITS algorithm stop? i.e. stopping points.<\/h3>\n<p class=\"wp-block-paragraph\"><strong>Answer.<\/strong> Stop when both vector changes fall below a tolerance, such as <code>max(\u2016h_new\u2212h\u2016\u2082,\u2016a_new\u2212a\u2016\u2082)&lt;\u03b5<\/code>, or after a fixed maximum number of iterations. More robust code combines both and reports if the tolerance was not reached.<\/p>\n<h3 class=\"wp-block-heading\">Q04.37. True or False, Destiny of PageRank and HITS were different. What does it mean?<\/h3>\n<p class=\"wp-block-paragraph\"><strong>Answer.<\/strong> 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.<\/p>\n<h3 class=\"wp-block-heading\">Q04.38. Can you stop the HITS algorithm after a certain number of iterations?<\/h3>\n<p class=\"wp-block-paragraph\"><strong>Answer.<\/strong> 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.<\/p>\n<h3 class=\"wp-block-heading\">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?<\/h3>\n<p class=\"wp-block-paragraph\"><strong>Answer.<\/strong> 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.<\/p>\n<h3 class=\"wp-block-heading\">Q04.40. What are contextual graphs, anyway?<\/h3>\n<p class=\"wp-block-paragraph\"><strong>Answer.<\/strong> A contextual graph is a subgraph selected for a purpose, time window, topic, or community\u2014for example, only pages on a university admissions topic or only transactions in the past 30 days. Selection choices influence the score.<\/p>\n<h3 class=\"wp-block-heading\">Q04.41. Give example use cases for HITS and PageRank?<\/h3>\n<p class=\"wp-block-paragraph\"><strong>Answer.<\/strong> 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.<\/p>\n<h3 class=\"wp-block-heading\">Q04.42. Can you think of the value aspect of these algorithms? i.e. how they affect people, communities, societies?<\/h3>\n<p class=\"wp-block-paragraph\"><strong>Answer.<\/strong> 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.<\/p>\n<h3 class=\"wp-block-heading\">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.<\/h3>\n<p class=\"wp-block-paragraph\"><strong>Answer.<\/strong> Python: <code>networkx.hits<\/code> and <code>networkx.pagerank<\/code>; igraph has PageRank and hub\/authority scoring in common bindings. R: <code>igraph::page_rank<\/code>, <code>hub_score<\/code>, <code>authority_score<\/code>. Check library versions and API documentation.<\/p>\n<h3 class=\"wp-block-heading\">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?<\/h3>\n<p class=\"wp-block-paragraph\"><strong>Answer.<\/strong> 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.<\/p>\n<h3 class=\"wp-block-heading\">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).<\/h3>\n<p class=\"wp-block-paragraph\"><strong>Answer.<\/strong> Main implementation pitfalls: treating A\u1d40 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.<\/p>\n<h2 class=\"wp-block-heading\">From-scratch Python: HITS and PageRank<\/h2>\n<pre class=\"wp-block-preformatted\">import numpy as np\n\nA = np.array([[1,1,1], [1,0,1], [0,1,0]], float)\nn = A.shape[0]\n\ndef unit(x):\n    z = np.linalg.norm(x)\n    return x \/ z if z else x\n\ndef hits(A, steps=100, tol=1e-12):\n    n = len(A); h = unit(np.ones(n)); a = unit(np.ones(n))\n    for _ in range(steps):\n        a1 = unit(A.T @ h)\n        h1 = unit(A @ a1)\n        if max(np.linalg.norm(h1-h), np.linalg.norm(a1-a)) < tol:\n            return h1, a1\n        h, a = h1, a1\n    return h, a\n\ndef pagerank(A, alpha=0.85, steps=200, tol=1e-12):\n    n = len(A)\n    P = A.copy().astype(float)\n    for i in range(n):\n        degree = P[i].sum()\n        if degree: P[i] \/= degree\n        else: P[i] = np.ones(n) \/ n   # dangling page\n    r = np.ones(n)\/n\n    for _ in range(steps):\n        rn = alpha * P.T @ r + (1-alpha)\/n\n        if np.linalg.norm(rn-r, 1) < tol: return rn\n        r = rn\n    return r\n\nh, a = hits(A)\nprint(\"hub:\", np.round(h, 3))\nprint(\"authority:\", np.round(a, 3))\nprint(\"PageRank:\", np.round(pagerank(A), 3))\n# Compare against networkx.hits and networkx.pagerank.<\/pre>\n<p class=\"wp-block-paragraph\">Debugging checklist: use a tiny known graph, inspect A and A\u1d40, verify nonnegative scores, check <code>sum(PageRank)\u22481<\/code> and <code>||hub||\u2082\u2248||authority||\u2082\u22481<\/code>, then compare rankings to NetworkX. Self-links are included in this historical example; real applications may remove them.<\/p>","protected":false},"excerpt":{"rendered":"<p>HITS and PageRank: original questions 04.26 through 04.45 with AI-generated explanations, matrices, convergence, and code.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":true,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[1905,1994],"tags":[],"class_list":["post-79112","post","type-post","status-publish","format-standard","hentry","category-graph-mining","category-graph-mining-1","item-wrap"],"jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":79111,"url":"http:\/\/bangla.sitestree.com\/?p=79111","url_meta":{"origin":79112,"position":0},"title":"Graph Mining &#8211; 1 | 04. HITS and PageRank \u2014 Part 1 (Q&#038;A)","author":"Sayed","date":"November 18, 2026","format":false,"excerpt":"HITS and PageRank: original questions 04.01 through 04.25 with AI-generated explanations, matrices, convergence, and code.","rel":"","context":"In &quot;Graph Mining&quot;","block_context":{"text":"Graph Mining","link":"http:\/\/bangla.sitestree.com\/?cat=1905"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":79103,"url":"http:\/\/bangla.sitestree.com\/?p=79103","url_meta":{"origin":79112,"position":1},"title":"Graph Mining &#8211; 1 | Course Index, Source Archive and 415-Question Bank","author":"Sayed","date":"November 18, 2026","format":false,"excerpt":"Complete graph mining blog archive: 33 source posts, 13 distinct question sets, 415 numbered prompts, source links, and selected previously published answer notes.","rel":"","context":"In &quot;Graph Mining&quot;","block_context":{"text":"Graph Mining","link":"http:\/\/bangla.sitestree.com\/?cat=1905"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":79125,"url":"http:\/\/bangla.sitestree.com\/?p=79125","url_meta":{"origin":79112,"position":2},"title":"Graph Mining &#8211; 1 | 13. Assignments and Project Prompts \u2014 Part 2 (Worked Answers)","author":"Sayed","date":"November 18, 2026","format":false,"excerpt":"Graph Mining course assignments part 2: worked answers for source prompts 13.04\u201313.06 with reproducible Python examples and project evaluation guidance.","rel":"","context":"In &quot;Graph Mining&quot;","block_context":{"text":"Graph Mining","link":"http:\/\/bangla.sitestree.com\/?cat=1905"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":16322,"url":"http:\/\/bangla.sitestree.com\/?p=16322","url_meta":{"origin":79112,"position":3},"title":"Graph Mining: Hits. Learn by finding Answers to the Following Questions. Can you answer the following questions?","author":"Sayed","date":"October 12, 2019","format":false,"excerpt":"Graph Mining: Hits. Learn by finding Answers to the Following Questions. What is HITS algorithm in Graph Mining esp. for Web? What does HITS stand for? What is another similar Algorithm? What are different between the PageRank algorithm and HITS? What is the PageRank algorithm? What is the purpose? Where\u2026","rel":"","context":"In &quot;Graph Mining&quot;","block_context":{"text":"Graph Mining","link":"http:\/\/bangla.sitestree.com\/?cat=1905"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":22879,"url":"http:\/\/bangla.sitestree.com\/?p=22879","url_meta":{"origin":79112,"position":4},"title":"Graph Mining: HITS Pagerank HUBS Anchors and Graph Theories","author":"Sayed","date":"March 21, 2021","format":false,"excerpt":"Resources to Learn From Resources:HITS Algorithmhttps:\/\/en.wikipedia.org\/wiki\/HITS_algorithmhttp:\/\/pi.math.cornell.edu\/~mec\/Winter2009\/RalucaRemus\/Lecture4\/lecture4.htmlLast modified: Thursday, 24 October 2019, 9:32 PM Read the resources above and Learn by finding Answers to the Following Questions. Can you answer the following questions? Graph Mining: Hits. Learn by finding Answers to the Following Questions. What is HITS algorithm in Graph Mining\u2026","rel":"","context":"In &quot;Graph Mining&quot;","block_context":{"text":"Graph Mining","link":"http:\/\/bangla.sitestree.com\/?cat=1905"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":79121,"url":"http:\/\/bangla.sitestree.com\/?p=79121","url_meta":{"origin":79112,"position":5},"title":"Graph Mining &#8211; 1 | 11. Link Prediction and Node Similarity \u2014 Part 1 (Q&#038;A)","author":"Sayed","date":"November 18, 2026","format":false,"excerpt":"Link Prediction, Part 1: questions 11.01\u201311.19 answered with similarity metrics, Katz, SimRank, code and evaluation.","rel":"","context":"In &quot;Graph Mining&quot;","block_context":{"text":"Graph Mining","link":"http:\/\/bangla.sitestree.com\/?cat=1905"},"img":{"alt_text":"Animated graph with a possible new link shown as a dashed orange connection.","src":"https:\/\/i0.wp.com\/bangla.sitestree.com\/wp-content\/uploads\/2026\/11\/graph-mining-1-network-growth-original-animation.gif?resize=350%2C200","width":350,"height":200},"classes":[]}],"jetpack_featured_media_url":"","_links":{"self":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/79112","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=79112"}],"version-history":[{"count":0,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/79112\/revisions"}],"wp:attachment":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=79112"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=79112"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=79112"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}