Advertisement
Guest User

Untitled

a guest
Oct 2nd, 2014
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.92 KB | None | 0 0
  1. bool generateShortestPath(string source,string target,imdb& db){
  2.  list<path> partialPaths; // functions as a queue
  3.  set<string> previouslySeenActors;
  4.  set<film> previouslySeenFilms;
  5.  path way(source);
  6.  partialPaths.push_back(way);
  7.  while(!partialPaths.empty() && (partiliaPaths.front()).pathLength <= 5){
  8.    way = partiliaPaths.front();
  9.    partiliaPaths.pop_front();
  10.    vector<film> films;
  11.    string name = way.getLastPlayer();
  12.    db.getCredits(name,films);
  13.    for(int i = 0; i < films.size(); i++){
  14.      previouslySeenFilms.insert(films[i]);
  15.      vector<string> actors;
  16.      db.getCast(films[i],actors);
  17.      for(int j = 0;j < actors.size();j ++){
  18.        previouslySeenActors.insert(actors[i]);
  19.        path clone = way;
  20.        clone.addConnection(films[i],actors[j]);
  21.        if(actors[j]==target){
  22.      cout << clone << '\n';
  23.      return true;
  24.      }
  25.        partialPaths.push_bach(clone);
  26.    }
  27.  }
  28.    return false;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement