Scanner input = new Scanner(System.in); System.out.println("Enter Which node to you start...."); int a = input.nextInt(); v[a] = 1; int x,y; int count=0; while(count<=5) { for(int i=0;i<6;i++){ int min=999; if(v[i]==1){ for(int j=0;j<6;j++){ if(graph[i][j]<min) { min=graph[i][j]; x=i; y=j; } }