/* * Created on Jul 15, 2007 * * Copyright (c) 2007, the JUNG Project and the Regents of the University * of California * All rights reserved. * * This software is open-source under the BSD license; see either * "license.txt" or * http://jung.sourceforge.net/license.txt for a description. */ package edu.uci.ics.jung.algorithms.scoring; import edu.uci.ics.jung.algorithms.scoring.util.ScoringUtils; import edu.uci.ics.jung.graph.Graph; import org.apache.commons.collections15.Transformer; /** * Assigns hub and authority scores to each vertex depending on the topology of * the network. The essential idea is that a vertex is a hub to the extent * that it links to authoritative vertices, and is an authority to the extent * that it links to 'hub' vertices. * *

The classic HITS algorithm essentially proceeds as follows: *

 * assign equal initial hub and authority values to each vertex
 * repeat
 *   for each vertex w:
 *     w.hub = sum over successors x of x.authority
 *     w.authority = sum over predecessors v of v.hub
 *   normalize hub and authority scores so that the sum of the squares of each = 1
 * until scores converge
 * 
* * HITS is somewhat different from random walk/eigenvector-based algorithms * such as PageRank in that: * * * This implementation has the classic behavior by default. However, it has * been generalized somewhat so that it can act in a more "PageRank-like" fashion: * * * @param the vertex type * @param the edge type * * @see "'Authoritative sources in a hyperlinked environment' by Jon Kleinberg, 1997" */ public class HITS extends HITSWithPriors { /** * Creates an instance for the specified graph, edge weights, and alpha * (random jump probability) parameter. * @param g the input graph * @param edge_weights the weights to use for each edge * @param alpha the probability of a hub giving some authority to all vertices, * and of an authority increasing the score of all hubs (not just those connected * via links) */ public HITS(Graph g, Transformer edge_weights, double alpha) { super(g, edge_weights, ScoringUtils.getHITSUniformRootPrior(g.getVertices()), alpha); } /** * Creates an instance for the specified graph and alpha (random jump probability) * parameter. The edge weights are all set to 1. * @param g the input graph * @param alpha the probability of a hub giving some authority to all vertices, * and of an authority increasing the score of all hubs (not just those connected * via links) */ public HITS(Graph g, double alpha) { super(g, ScoringUtils.getHITSUniformRootPrior(g.getVertices()), alpha); } /** * Creates an instance for the specified graph. The edge weights are all set to 1 * and alpha is set to 0. * @param g the input graph */ public HITS(Graph g) { this(g, 0.0); } /** * Maintains hub and authority score information for a vertex. */ public static class Scores { /** * The hub score for a vertex. */ public double hub; /** * The authority score for a vertex. */ public double authority; /** * Creates an instance with the specified hub and authority score. */ public Scores(double hub, double authority) { this.hub = hub; this.authority = authority; } @Override public String toString() { return String.format("[h:%.4f,a:%.4f]", this.hub, this.authority); } } }