I believe your (heavily edited) fix is this:
int one_to_two(int* a, int x, int y)
{
return a[x*ROWS+y];
}
void dfs(int** G,int i,int *visited) {
int size = ROWS * COLUMNS ;
visited[i]=1;
int j;
for(j=0;j<size;j++) {
if(!visited[j]&& one_to_two(G,i,j) == 1)
dfs(G,j,visited);
}
}
That being said, I don't think that this is a well-structured method of solving this problem. I don't know why you're using recursion to do this, an iterative loop would be much simpler. This method has the possibility to blow-up the stack. You are NOT using tail recursion here, so this method will cause memory problems if ROWS or COLUMNS gets very large.
I apologize for my screw-ups, the typing didn't work quite the way I thought it did. This will require casting your 2-d array to an int pointer before sending it into the function. I'm not sure I like this solution, its not very elegant, but it should at least compile.
On another note, not quite sure what you're trying to do with depth-first search, but I don't think this algorithm does quite what you you think it does (for one, malloc doesn't zero the memory it allocates, which is of particular concern for this algorithm)