We were tasked by our professor to create a graph implementation for a directed weight graph. I started off by creating a vector that accepts a pair of integers which is the edge and its weight. Now I am trying to find a way to implement DFS for the graph but I was unable to. Here is my code. I am sorry if I did not follow the guidelines since I am new to this.
void Graph::DFSUtil(int v, bool visited[])
{
visited[v] = true;
cout << v << " ";
vector<pair<int,int>> :: iterator i;
for (i = adj[v].begin(); i != adj[v].end(); ++i)
if(!visited[*i->first])
DFSUtil(*i->first, visited);
}
void Graph::DFS(int v)
{
bool visited[vertices];
for (int i = 0; i < vertices; ++i){
visited[i] = false;
}
}
I keep getting the error:
invalid type argument of unary '*' (have 'int')
Can somebody please explain what I did wrong?