I am trying to implement a graph that contains Vertices(nodes) that relate to a Profile
class(like a Facebook profile but more mediocre). Each of the vertices(Profiles) is stored in a Binary Search Tree which is then loaded or stored in an Array-List.
Just like in a Facebook Profile
some (not all since not everyone has friends) instances of the class Profile
will have friends which are the edges.
Each edge relationship of the graph is stored in a text file which is then read in and added to the graph by a separate method during the graph construction.
Once this is done I am trying to implement a recommended method:
Two profiles that are not friends but will like to be friends based on the relationship possibly being a triadic closure but I have failed terribly so far and I am currently stuck.
- Currently, I was able to create a graph using a
Matrix
but I am stuck with trying to find a possible solution to recommend possible friends for each vertex that has a friendj
who has a friendx
who is not a friend of the vertex(current Profile). Each one of the recommended friends is supposed to be stored into an array and added to a Binary Search Tree.
private List<Profile> getRecommendedFriends(){ Iterator profileIterator = this.vertexProfileMap.entrySet().iterator(); List<Profile> recommendedProfiles = new ArrayList<>(); Boolean isContained; while(profileIterator.hasNext()){ Map.Entry mapElement = (Map.Entry)profileIterator.next(); Profile user = (Profile) mapElement.getValue(); int sizeOfList = user.numOfFriends(); for(int i = 0; i < sizeOfList; i++){ recommendedProfiles.add(user.getFriend(i)); for(int x = 0; x < user.numOfFriends(); x++){ for(int j = 0; j < user.numOfFriends(); j++){ isContained = user.getFriend(x).getName().equals(user.getFriend(j).getName()); if(!isContained){ recommendedProfiles.add(user.getFriend(j)); } } } } } return recommendedProfiles; }