learngraphtheory.org

Guest

Sign in to keep your graphs and progress.

Cover of the book Graph Theory Through Problems

Practice book

Graph Theory Through Problems

300 Exercises with Hints, Worked Algorithms and Complete Solutions

By Mohammed Islam Hadjoudj

Learn graph theory by solving problems: 300 exercises, from routine checks to challenging proofs, each with a complete solution.

Available inKindlePaperback

13 chapters

Also by the authorGraph Algorithms for Coding Interviews100 solved interview problems with visual explanations and Python solutions.View on Amazon
Algorithm Selection

Select an algorithm and generate steps to begin visualization

HITS Algorithm Visualizer

Hubs point to authorities

Kleinberg's link analysis: authorities are pages good hubs link to, hubs are pages that link to good authorities, updated in turn until they settle

Time: O(k(V + E))
Space: O(V)
Use Case: Web search ranking, citation analysis, expert finding
Showing the example graph for this algorithm.
Algorithm Execution

Select an algorithm and generate steps to begin visualization

About HITS (Hubs and Authorities)

HITS (Hyperlink-Induced Topic Search) is a link-analysis algorithm by Jon Kleinberg (1999) that gives every page of a directed graph two scores. The authority score says how valuable a page is as a source of information: many good hubs link to it. The hub score says how valuable a page is as a list of links: it points to many good authorities. The two definitions depend on each other, and HITS breaks the circle by iteration. It was developed at IBM's Almaden research center around the same time as PageRank, and the two are the classic algorithms of web search ranking.

How it works

Every page starts with hub and authority score 1/n. Each round first sets every authority to the sum of the hub scores of the pages that link to it, then every hub to the sum of the new authority scores of the pages it links to. After each update the scores are scaled to add up to 1, so they do not grow without bound. With A the adjacency matrix, the authorities converge to the leading eigenvector of AᵀA and the hubs to that of AAᵀ. The visualizer shows the first round vertex by vertex, authorities first, then one step per round until no score changes by more than 0.0001. The size of a vertex shows its authority, the badge its hub score.

Applications

Kleinberg designed HITS to rank web pages for a query: collect the pages about a topic and their neighbours, then let the hubs (directories, link lists, review pages) and the authorities (the pages they recommend) emerge. The same idea ranks papers and surveys in citation networks, experts and helpful answerers in question-and-answer communities, and sources and aggregators in news and social media. The search engine Teoma, later Ask.com, used a HITS-style ranking. In directed biological and economic networks, hub and authority scores separate regulators from regulated genes and suppliers from customers.

Pseudocode

HITS alternates two updates, each a sum over the links in one direction, and rescales the scores after each update.

HITS(G, tol = 0.0001):
    hub[v] = auth[v] = 1 / n for every vertex v
    repeat:
        for each vertex v:
            auth[v] = Σ hub[u]   over links u → v
        auth = auth / sum(auth)
        for each vertex v:
            hub[v] = Σ auth[w]   over links v → w
        hub = hub / sum(hub)
    until no score changes by more than tol
    return hub, auth

Kleinberg scaled the vectors to Euclidean length 1. NetworkX and this visualizer scale them to a sum of 1, which changes the numbers but not the ranking. The hub update uses the authorities just computed, which is the standard order.

Worked example, step by step

Load the example: a small web of directory pages on top and content pages below.

Example graph: A links to D, E and F. B links to D and E. C links to D and F. G links to D and to three pages, H, I and J, that no other page links to. G has the most links, four, and A has three.

  1. Round 1, authorities. Every hub starts at 0.1. D is linked from A, B, C and G, so its authority is 0.4. E and F get 0.2, H, I and J 0.1 each, and the pages without incoming links get 0.
  2. Round 1, hubs. After scaling, A's hub score is the sum of the authorities of D, E and F, 0.727, ahead of G (0.636), B and C (0.545). G's extra links only reach the weak pages H, I and J.
  3. Rounds 2 to 4. The scores reinforce each other: A's strong hub score lifts D, E and F, which lifts A again. After four rounds no score moves by more than 0.0001.
  4. The result. Authorities D 0.355, E and F 0.184 each. Hubs A 0.297, G 0.259, B and C 0.222 each. The content pages have hub score 0 and the directory pages authority 0.

A is the best hub although G has more links: three of G's four links point to pages that nobody else recommends. This is the core idea of link analysis: a link counts by who makes it and where it points, not by how many there are.

Complexity, and where it comes from

Time: O(k(V + E)) · Space: O(V)

Each round reads every link twice, once for the authorities and once for the hubs, so it costs O(V + E). The number of rounds k depends on the gap between the two largest eigenvalues of AᵀA. In Kleinberg's setting HITS ran at query time on a small subgraph of a few thousand pages, the search results plus their neighbours, so it was fast enough, unlike PageRank, which is computed once for the whole web. Two score vectors of length V are kept.

When to use HITS (Hubs and Authorities), and when not to

HITS and its relatives rank the vertices of a directed graph by the links between them.

AlternativePrefer it whenCost
HITSTwo roles, sources (authorities) and directories (hubs), on a topic subgraph built for one query.O(k(V + E)) per query
PageRankOne global importance score per page, computed once offline for the whole graph.O(k(V + E)) once
SALSAA random-walk version of HITS (Lempel and Moran 2000) that is less dominated by one tightly linked group.O(k(V + E))
In-degreeA quick baseline: it counts links without weighing who made them.O(V + E)

Common pitfalls

  • Tightly knit communities. A group of pages that all link to each other can pull the leading eigenvector towards itself and take most of the score, even when it is off-topic. This is the TKC effect, and SALSA or a damping term reduce it.
  • Undirected graphs. If every link goes both ways, AᵀA and AAᵀ are the same matrix and the hubs equal the authorities. There HITS adds nothing over eigenvector centrality.
  • Ties in the leading eigenvalue. When AᵀA has two equal largest eigenvalues, for example on two separate groups of the same shape, the result depends on the starting scores. Starting from equal scores, as here, keeps it repeatable.
  • Hub and authority are not opposites. A page can be both: a review site that links to good products and is itself linked from good directories. Read the two scores separately, not as one ranking.

Frequently asked questions

What are hubs and authorities?
An authority is a page with valuable content, recognized by many links from good hubs. A hub is a page that collects links to good authorities, such as a directory or a curated list. Each score is defined through the other, and HITS computes both together.
What is the difference between HITS and PageRank?
PageRank gives every page one score, computed once for the whole web and independent of the query. HITS gives two scores, hub and authority, computed at query time on a subgraph of pages related to the query. PageRank also adds a random jump, so it never gets stuck.
Does HITS always converge?
Yes, as long as the graph has links, because the updates are power iterations on AᵀA and AAᵀ, which are symmetric and nonnegative. If several eigenvectors share the largest eigenvalue, the limit depends on the starting scores.
How do I run HITS in Python?
NetworkX provides nx.hits(G), which returns two dictionaries, hubs and authorities, each scaled to a sum of 1 as in this visualizer. It works on directed graphs, and on undirected ones the two dictionaries come out equal.

Related algorithms: PageRank, Eigenvector Centrality, Personalized PageRank, Betweenness Centrality

An example graph: you can change it, or start blank.

Zoom Controls

30%
Nodes: 10
Edges: 11