-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathFriend.java
More file actions
36 lines (30 loc) · 844 Bytes
/
Copy pathFriend.java
File metadata and controls
36 lines (30 loc) · 844 Bytes
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
import java.io.Serializable;
import java.util.HashMap;
public class Friend implements Comparable, Serializable {
// Basic Elements
public String name;
public String id;
// The value in each k-v pair here is the weight of the edge between
// this user and that friend.
// Weight is defined as Math.floor(1000 / (number of mutual friends + 1))
// where mutual friends = number of friends two users have in common in
// the graph.
public HashMap<Friend, Integer> friends;
public Friend() {
friends = new HashMap<Friend, Integer>();
}
@Override
public String toString() {
return null;
}
// Suitable as facebook IDs are unique
@Override
public int hashCode() {
return (Long.decode(id).hashCode());
}
@Override
public int compareTo(Object o) {
Friend friend = (Friend) o;
return this.id.compareTo(friend.id);
}
}