forked from eason9338/InternNet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWebNode.java
More file actions
57 lines (49 loc) · 1.06 KB
/
Copy pathWebNode.java
File metadata and controls
57 lines (49 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import java.io.IOException;
import java.util.ArrayList;
public class WebNode
{
public WebNode parent;
public ArrayList<WebNode> children;
public WebPage webPage;
public double nodeScore;// Webpage total Score
//constructor
public WebNode(WebPage webPage)
{
this.webPage = webPage;
this.children = new ArrayList<WebNode>();
}
//計算網頁分數
public void setNodeScore(ArrayList<Keyword> keywords) throws IOException
{
webPage.setScore(keywords);
nodeScore = webPage.score;
for(WebNode w:children) {
nodeScore += w.nodeScore;
}
}
//加入子網頁
public void addChild(WebNode child)
{
this.children.add(child);
child.parent = this;
}
//確定是否最後的子網業
public boolean isTheLastChild()
{
if (this.parent == null)
return true;
ArrayList<WebNode> siblings = this.parent.children;
return this.equals(siblings.get(siblings.size() - 1));
}
public int getDepth()
{
int retVal = 1;
WebNode currNode = this;
while (currNode.parent != null)
{
retVal++;
currNode = currNode.parent;
}
return retVal;
}
}