Coders Packet

Friends Suggestion Algorithm in Python

By Cheshta Babbar

Social media checks your friends list and looks for mutual friends. These mutual friends are shown as suggestions on your timeline. For example, your siblings friends could be people you know.

This python application demonstrates social media friend connections using the graph data structure.

A simple social media platform can be considered as a graph where each user is a node and a friend connection between two users can be depicted by an edge of the graph.

This program takes a set of users among which some are friends with each other, the program then works to give a list of friend suggestions for a particular user based on his current friend list. This suggestions list is given as an output in the first output that the program generates.

The second output window prints a graph of all the users in the social media and their friend connections using python's NetworkX and Matplotlib libraries.

The social media friend graph is defined as an adjacency matrix of all users where each friend connection is detected as a 1 and a non-connection is depicted as a 0.

Download Complete Code


No comments yet