title: Optimized search.How to reduce the complexity ?
body: <p>Here is a problem I'm trying to solve using graph algorithms. Answer to this question is easy if one is familiar with different graph traversal algorithms. What I want to learn is how can we reduce the complexity of this problem?</p>
  
  <blockquote>
    <p>Let say we have to traverse in someone's network - Friends, Friends of
    Friends (FoF) and FoFoF (1st, 2nd, 3rd Degree.. up to 6th degree) to
    search for a particular thing, say 'people living in California'. The
    complexity of the problem greatly increases when you have 1000 friends
    and your 1000 friends have 1000 friends each and so on.</p>
    
    <p>Let's say we want to do an optimized search, where you know the
    destination node (here, a person living in California). How will you
    reduce the complexity of the problem?</p>
    
    <p>The program you submit should return the degree by which that person
    is connected to you. [where the 'destination node' is your Degree 1st
    (Friend), or 2nd (friend of friend) or 3rd Degree (FoFoF) or a Degree
    greater than 3rd degree].</p>
  </blockquote>