Length of the longest path ending at vertex V in a Graph

#include
using namespace std;
  

void dfs(int src, vector Adj[],
         vector& visited, int level,
         int& distance)
{
  
    
    visited[src] = true;
  
    
    distance = max(distance, level);
  
    
    
    for (auto& child : Adj[src]) {
  
        
        
        if (child != src
            and visited[child] == false) {
            dfs(child, Adj, visited,
                level + 1, distance);
        }
    }
  
    
    visited[src] = false;
}
  

int maximumLength(vector& mat,
                  int V)
{
  
    
    
    int distance = 0;
  
    
    int N = (int)mat.size();
  
    
    
    vector Adj[N];
  
    vector visited(N, false);
  
    
    
    for (int i = 0; i < N; i++) {         for (int j = 0; j < N; j++) {             if (mat[i][j] == 1) {                 Adj[i].push_back(j);             }         }     }                  dfs(V, Adj, visited, 0, distance);        return distance; }    int main() {     vector mat = { { 0, 1, 0, 0 },                                  { 1, 0, 1, 1 },                                  { 0, 1, 0, 0 },                                  { 0, 1, 0, 0 } };     int V = 2;        cout