Is the complexity of this topological sort algorithm O(P+D) where P is projects and D is dependencies?

I have written a topological sorting algorithm in c++ but i am not sure if the complexity is as good as it should be. I know theres a topological sort algorithm that works in O(P+D) time where p is projects and D is number of dependencies, but I am unsure if i wrote it correctly. Can you take a look? Code is below. Any other suggestions on improvement is welcome too, I feel like having 2 lists for adjacency is inefficient and I think there should be a better way to do it.

#include <iostream> #include <string> #include <unordered_map> #include <unordered_set> #include <queue> using namespace std;  class Graph{ public:     Graph(vector<string> projects, vector<pair<string,string>> dependencies)     {            int counter=0;         for(int i=0;i< projects.size();i++)         {             strToInt[projects[i]]=counter++;             }         adjList.resize(projects.size());         for(int i=0;i<dependencies.size();i++)         {             adjList[strToInt[dependencies[i].second]].first.insert(strToInt[dependencies[i].first]);             adjList[strToInt[dependencies[i].first]].second.push_back(strToInt[dependencies[i].second]);         }     }     vector<pair<unordered_set<int>,vector<int>>> adjList;     unordered_map<string,int> strToInt;     bool BuildOrder(){         vector<int> visited(adjList.size(),0);         queue<int> q;         int count =0;         for(int i=0;i<adjList.size();i++)         {             if(adjList[i].first.size()==0)             {                 count++;                 q.push(i);             }         }         while(!q.empty())         {             count++;             int temp=q.front();             q.pop();             visited[temp]=1;             for(int i=0;i<adjList[temp].second.size();i++)             {                 adjList[i].first.erase(temp);                 if(adjList[i].first.size()==0&&visited[i]==0)                 {                     q.push(i);                 }             }         }         if(count==visited.size())         {             return true;         }         return false;     }   };  int main() {     vector<string> projects;     projects.push_back("a");     projects.push_back("b");     projects.push_back("c");     projects.push_back("d");     projects.push_back("e");     projects.push_back("f");     vector<pair<string,string>> dependencies;     dependencies.push_back(make_pair("a","d"));     dependencies.push_back(make_pair("f","b"));     dependencies.push_back(make_pair("b","d"));     dependencies.push_back(make_pair("f","a"));     dependencies.push_back(make_pair("d","c"));     Graph g(projects,dependencies);     bool temp=g.BuildOrder();     return 0; } ```