public void shortestPath(int vertex){
        for(int i = 0; i < gSize; i++)
            smallestWeight[i] = weights[vertex][i];
        
        boolean[]weightFound = new boolean[maxSize];
        
        for(int i = 0; i < gSize - 1; i++){
            double minWeight = Integer.MAX_VALUE;
            int v =0;
            
            for(int j = 0; j< gSize; j++)
                if(!weightFound[j])
                    if(smallestWeight[j] < minWeight){
                        v = j;
                        minWeight = smallestWeight[v];
                    }
            
            weightFound[v] = true;
            
            for(int j = 0; j < gSize; j++)
                if(!weightFound[j])
                    if(minWeight + weights[v][j] < smallestWeight[j])
                        smallestWeight[j] = minWeight + weights[v][j];
        }
    }