-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSocialNetworkNode.pde
52 lines (45 loc) · 1.18 KB
/
SocialNetworkNode.pde
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
class SocialNetworkNode{
boolean hasBreadcrumb;
Agent data;
SocialNetworkNode parent; // first node that added this to the social network
/** initializes a new SocialNetworkNode storing the passed agent.
* The node initially does not contain a breadcrumb.
*/
public SocialNetworkNode(Agent a){
this.hasBreadcrumb = false;
this.data = a;
this.parent = null;
}
/** returns true if this node has a breadcrumb.
*/
public boolean hasBreadcrumb(){
return this.hasBreadcrumb;
}
/** Places a breadcrumb on the node.
*/
public void placeBreadcrumb(){
this.hasBreadcrumb = true;
}
/** Gets this node's parent, the first node that added this node to the search
*/
public SocialNetworkNode getParent(){
return this.parent;
}
/** Helper for placeBreadcrumb().
*/
private void placeBreadcrumb(SocialNetworkNode parent){
this.parent = parent;
placeBreadcrumb();
}
/** Removes any breadcrumb from the node.
*/
public void removeBreadcrumb(){
this.hasBreadcrumb = false;
this.parent=null;
}
/** Returns the agent stored at this node.
*/
public Agent getAgent(){
return this.data;
}
}