is this a correct way to analyze a graph ? : Hi guys I need help with analyzing a graph , I have implemented Dijkstra algorithm but i'm not sure about my analysis.
is this a correct way to analyze a graph ? 

my analysis are in the comments.


public class Dijkstra {


        
     
        for (int i = 0; i < distance.length; i++)//O(v^2)
        {
            visited[i] = 0; 
            preD[i] = 0;
 
            for (int j = 0; j < distance.length; j++)
            {
                matrix[i][j] = scan.nextInt(); 
                if (matrix[i][j]==0)
                    matrix[i][j] = 999; 
            }
        }
 
     
        for (int counter = 0; counter < n; counter++)//O(V^2) 
        {
            min = 999;
            for (int i = 0; i < 3; i++)
            {
                if (min > distance[i] && visited[i]!=1) 
                {
                    min = distance[i];
                    nextNode = i;
                }
            } 
 
         
            
            
            for (int i = 0; i < n; i++)//O(E) 
            {
                if (visited[i]!=1)
                {
                    if (min+matrix[nextNode][i] < distance[i])
                    {
                        distance[i] = min+matrix[nextNode][i]; 
                        preD[i] = nextNode;
                    }
 
                }
 
            }
 
        }//finally Dijkstra takes O(v^2) 
}
