<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Aman Srivastav on Medium]]></title>
        <description><![CDATA[Stories by Aman Srivastav on Medium]]></description>
        <link>https://medium.com/@amancs18997?source=rss-522c20e0610d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*xQZckFZTPz4_DWGS293PXA.jpeg</url>
            <title>Stories by Aman Srivastav on Medium</title>
            <link>https://medium.com/@amancs18997?source=rss-522c20e0610d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 13:05:51 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@amancs18997/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Introduction to Graphs & how facebook get friends suggestions]]></title>
            <link>https://medium.com/@amancs18997/introduction-to-graphs-how-facebook-get-friends-suggestions-39e0689576c0?source=rss-522c20e0610d------2</link>
            <guid isPermaLink="false">https://medium.com/p/39e0689576c0</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[facebook]]></category>
            <category><![CDATA[graph]]></category>
            <dc:creator><![CDATA[Aman Srivastav]]></dc:creator>
            <pubDate>Thu, 04 Oct 2018 07:32:31 GMT</pubDate>
            <atom:updated>2018-10-04T07:34:53.817Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction to graphs &amp; how facebook get friend suggestions</h3><p><a href="https://www.geeksforgeeks.org/graph-data-structure-and-algorithms/">Graph </a>creates a great interest in computer science &amp; as well as research in recent past.Since 1980, with the invent of internet their has been a great interest in this area, specially in computer science.</p><p>With the invent of internet,they represent the entire World Wide Web as a graph. So every webpage is a actually a node(vertices),and their is a link from one webpage to other webpage,that is an edge(links).Therfore entire WWW can now be modelled as a graph.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kIQuAsHDG5mkxORdQxdMRg.jpeg" /></figure><p>And now we are interested in knowing various property of this graph,exploring various property based on search is going to be relevent and search time everything can be improved.</p><p>Moreover with the invent of social network, like facebook and other social networking sites, what actually happen is,</p><p>they started representing this entire social network also as a graph. If you are a person you actually a ‘node’ in a graph and if you having friends are also nodes in the graph and you will have a link like this as follows-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4irMVKpTvuE3cw4MC4NJcQ.png" /></figure><p>In Facebook, their is a friend suggestions and shows that this person might be your friends. How is that posible?</p><p>-well they do some traversals…</p><p>The most important points about graphs is all the problems are from “traversal” and “search”. Now the information is present in the graph and we have to get that information out. So how do we read the information?</p><p>-just by ‘traversing’ or ‘searching’…. simply :)</p><p>Now the issue is friend suggestions by which they may see your friends .So,how to get that?</p><p>solution for this is if we denote profile as a node in the social network, then what is the friend list, friend list is nothing but the adjacency list (acc. to graph concept). so, adjacency list in a graph is equal to friend list in the facebook. gotit!…</p><p>and now, their is a problem that you may know a person whom your friend might know, right!…</p><p>therefore we start from a particular node and try to search, so how do we search? hmmm… , we search in a <a href="https://www.geeksforgeeks.org/breadth-first-search-or-bfs-for-a-graph/">BFS(breadth first search)</a> manner.</p><p>It searches all the elements which are at a distance one.These elements are nothing but all your friends. Again, we search all the elements which are at distance two, these are friends of your friend and so on… get that? NO!</p><p>take a look in the given diagram-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/328/1*rYsO2dzCjPEHZ1i-eUJtFQ.png" /></figure><p>let E be your profile, then your friends are B,G,C, these are at distance 1, and A,F,D, at distance 2(friends of your friends). and continues….</p><p>If we try BFS,start from a node and try exploring your friends,and then friends of your friends… , then you might get people whom you might know.So that is how facebook will give you the suggestions.</p><p>A modified version of this.</p><p>Their is one more search type called <a href="https://www.geeksforgeeks.org/depth-first-search-or-dfs-for-a-graph/">DFS(depth first search)</a>. It actually says that you go as deep as possible and find the value(some person) their.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9I1rD2Mi673TyfhrCcdS1A.jpeg" /></figure><p>lets say ,if you are in india,it might stop at some person in a USA,and you might not know him/her at all. Therefore DFS fails here.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=39e0689576c0" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>