I'm attempting to do a DFS search on a certain graph, here I have attempted to write down the following code (I'm aware that there are many errors/warnings and mistakes I have made but this is only a start and I need some help).
int visited[];
static int last=-1;
int record_of_visit[];
void print_dfs(Graph* graph, int source_id)
{
//printf("not yet implemented: put code for part 1 here\n");
visited[source_id]=1;
record_of_visit[++last]=source_id;
int i;
for (i=0;i<20;i++)
{
if (graph[source_id][i]==1)
{
if(visited[i] == 0)
print_dfs(graph,i);
}
}
}
The graph.c file implementing the adjacency list can be found here.
The graph.h file can be found here.
Here I am trying to access the graph which is an already built adjacency list, but the compiler would give me error when I run this program indicating that
on if (graph[source_id][i]==1)
subscripted value is neither array nor pointer
What am I doing wrong here? Also any tips or suggestions on what to improve in my still raw DFS implementation would be appreciated!