public int findShortestPass(HashMap<Integer, Vertex> G, int from, int to) {

        PriorityQueue<Vertex> Q = new PriorityQueue<Vertex>();

        setNewMinDist(G, from, 0, from);
        Q.add(G.get(from));

        while(!Q.isEmpty()){

            Vertex u = Q.poll();

            if(u.Vertex == to) break; // found shortest path to needed vertex

            if(!G.get(u.Vertex).discovered){
                u.discovered = true;

                for(int v: G.get(u.Vertex).edges()){
                    relax(G, u, v);
                    Q.add(G.get(v));
                }
            }
        }

        return G.get(to).minDistance;
    }