Skip to content

Commit

Permalink
corrected HITS calculation (issue #620)
Browse files Browse the repository at this point in the history
- initialized authority and hubs to 1 at each iteration
- used outgoing edges instead of incoming edges for hubs computation
- renamed 'target' to source for incoming edges in authority computation

Review of the logic would be appreciated.

Normalization is different from the one in the original paper, but this might not be affecting the logic. networkx uses same normalization logic as the one used here.
  • Loading branch information
mef committed Mar 8, 2013
1 parent c8de4a1 commit 5c35da8
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,17 +170,17 @@ public void execute(HierarchicalGraph hgraph, AttributeModel attributeModel) {
for (Node node : auth_list) {

int n_index = indicies.get(node);
temp_authority[n_index] = authority[n_index];
temp_authority[n_index] = 1.0f;
EdgeIterable edge_iter;
if (!useUndirected) {
edge_iter = ((HierarchicalDirectedGraph) hgraph).getInEdgesAndMetaInEdges(node);
} else {
edge_iter = ((HierarchicalUndirectedGraph) hgraph).getEdgesAndMetaEdges(node);
}
for (Edge edge : edge_iter) {
Node target = hgraph.getOpposite(node, edge);
int target_index = indicies.get(target);
temp_authority[n_index] += hubs[target_index];
Node source = hgraph.getOpposite(node, edge);
int source_index = indicies.get(source);
temp_authority[n_index] += hubs[source_index];
}

auth_sum += temp_authority[n_index];
Expand All @@ -194,10 +194,10 @@ public void execute(HierarchicalGraph hgraph, AttributeModel attributeModel) {
for (Node node : hub_list) {

int n_index = indicies.get(node);
temp_hubs[n_index] = hubs[n_index];
temp_hubs[n_index] = 1.0f;
EdgeIterable edge_iter;
if (!useUndirected) {
edge_iter = ((HierarchicalDirectedGraph) hgraph).getInEdgesAndMetaInEdges(node);
edge_iter = ((HierarchicalDirectedGraph) hgraph).getOutEdgesAndMetaOutEdges(node);
} else {
edge_iter = ((HierarchicalUndirectedGraph) hgraph).getEdgesAndMetaEdges(node);
}
Expand Down

0 comments on commit 5c35da8

Please sign in to comment.