资源简介
java实现HITS算法。
包含一个文档说明。文档是用的别人的。

代码片段和文件信息
package hits;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class HITS {
WebGraph webGraph;
Map authorityScores;
Map hubScores;
int nodeCount;
public HITS(WebGraph webGraph)
{
this.webGraph=webGraph;
this.authorityScores = new HashMap();
this.hubScores = new HashMap();
this.nodeCount = webGraph.getNodeCount();
// 初始的内容权威度和链接权威度均设为1
for (int i = 0; i < webGraph.getNodeCount(); i++) {
this.authorityScores.put(i 1.0);
this.hubScores.put(i 1.0);
}
// 计算结点的内容权威度和链接权威度 指定最大迭代次数为25
computeHITS(1000);
}
/**
* 计算结点的内容权威度和链接权威度
* @param numIterations 最大迭代次数
*/
private void computeHITS(int numIterations) {
// 迭代次数
int iterNum = numIterations;
// 上一次迭代的内容权威度和链接权威度 初始值均设为0
Map preAuthorityScore = new HashMap();
Map preHubScore = new HashMap();
for (int i = 0; i < nodeCount; i++) {
preAuthorityScore.put(i 0.0);
preHubScore.put(i 0.0);
}
System.out.println(“第0次迭代:“);
printAuthorAndHub();
// 如果未达到最大迭代次数或未收敛 则继续迭代
while ((numIterations--) > 0&& !isConvergence(preAuthorityScore authorityScores
preHubScore hubScores))
{
System.out.println(“第“ + (iterNum - numIterations) + “次迭代:“);
for (int i = 0; i < nodeCount; i++) {
List inlinks = webGraph.getInlinks(i); // 入链接集
double authorityScore = 0; // 内容权威度
for (Integer in : inlinks) {
//System.out.println(in);
// 内容权威度等于所有入链接的链接权威度之和
authorityScore += hubScores.get(in).doubleValue();
}
authorityScores.put(i authorityScore);
}
for (int i = 0; i < nodeCount; i++) {
List outlinks = webGraph.getOutlinks(i); // 出链接集
double hubScore = 0; // 链接权威度
for (Integer out : outlinks) {
//System.out.println(out);
// 链接权威度等于所有出链接的内容权威度之和
hubScore += authorityScores.get(out).doubleValue();
}
hubScores.put(i hubScore);
}
// 归一化(使用最大值)
double aMax = getMaxValue(authorityScores);
double hMax = getMaxValue(hubScores);
for (int i = 0; i < nodeCount; i++) {
double aScore = authorityScores.get(i);
double hScore = hubScores.get(i);
authorityScores.put(i aScore / aMax);
hubScores.put(i hScore / hMax);
}
// 输出每次迭代所得的值
printAuthorAndHub();
}
}
private boolean isConvergence(Map preAuthorityScore
Map authorityScores2
Map preHubScore Map hubScores2) {
for(int i=0;i {
double e= Math.abs(authorityScores2.get(i)-preAuthorityScore.get(i))+Math.abs(hubScores2.get(i)-preHubScore.get(i));
if(e<0.00001)
{
return true;
}
}
return false;
}
private double getMaxValue(Map authorityScores2) {
double max=0;
for(int i=0;i
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 301 2015-01-25 11:12 HITS\.classpath
文件 380 2015-01-25 11:12 HITS\.project
文件 598 2015-01-25 11:12 HITS\.settings\org.eclipse.jdt.core.prefs
文件 4580 2015-01-25 14:16 HITS\bin\hits\HITS.class
文件 956 2015-01-25 13:38 HITS\bin\hits\Main.class
文件 4441 2015-01-25 14:08 HITS\bin\hits\WebGraph.class
文件 34 2015-01-25 11:25 HITS\hits.txt
文件 3664 2015-01-25 14:16 HITS\src\hits\HITS.java
文件 466 2015-01-25 13:38 HITS\src\hits\Main.java
文件 3206 2015-01-25 14:08 HITS\src\hits\WebGraph.java
文件 110592 2015-01-25 14:24 HITS\信息检索之HITS算法.doc
目录 0 2015-01-25 14:28 HITS\bin\hits
目录 0 2015-01-25 14:28 HITS\src\hits
目录 0 2015-01-25 14:28 HITS\.settings
目录 0 2015-01-25 14:28 HITS\bin
目录 0 2015-01-25 14:28 HITS\src
目录 0 2015-01-25 14:28 HITS
----------- --------- ---------- ----- ----
129218 17
- 上一篇:java聊天小程序.java聊天小程序
- 下一篇:Java通过邮箱找回密码和注册
相关资源
- 推荐算法的JAVA实现
- [免费]java实现有障碍物的贪吃蛇游戏
- 操作系统作业 (pv,作业管理,等5个
- 一元多项式相加 java实现
- java实现的svn统计修改代码行数完整源
- java实现小型函数画图板(附源代码、
- java实现的搜索引擎
- 数据库设备管理系统课程设计论文J
- Java实现的聊天室,具有群聊和私聊功
- java实现的网络五子棋
- java实现的QQ登录界面
- java实现POS系统源码
- 用Java实现TCP通信
- java实现验证码代码
- Java实现的公交查询系统代码
- 扫描二维码 JAVA实现20190403
- java实现软件锁屏功能
- java实现生成Excel默认.xls,可自己修改
- C#和Java实现互通的RSADES加解密算法
- JS实现AES-GCM加密,java实现AES-GCM解密。
- PDFBOX JAR包
- java实现Socket方式文件批量传输/上传到
- Java实现获取窗口句柄并操作窗口jna
- java实现websocket简单demo
- java实现输入任意两个日期输出月份数
- JAVA实现ICTCLAS2015分词
- 网上超市购物结算功能模拟 java实现
- 24点游戏Java实现
- java实现发送短信验证码功能
- java实现的水果忍者游戏
评论
共有 条评论