public int getDistance(String from, String to)
            throws EmptyGraphException, UnreachableVertexException, OutOfGraphException {
        int n = vertices.size();
        if (n == 0){
            throw new EmptyGraphException();
        }
        else{
        Vertex source = null;
        Vertex target = null;

        int i = 0, count = 0;
        while (i <n && count != 2){
            String name = vertices.get(i).getName();
            if (name == from){
                source = vertices.get(i);
                count++;
            }
            else if (name == to){
                target = vertices.get(i);
                count++;
            }
            i++;
        }

        if (count != 2)
            throw new OutOfGraphException();
        else{
        distance.put(source, 0);
        unvisited.add(source);
        while (unvisited.size() > 0) {
            Vertex vertex = getMinimum(unvisited);
            visited.add(vertex);
            unvisited.remove(vertex);
            findMinimalDistances(vertex);
        }

        int d = algorithmDistance(target);
        if (d == Integer.MAX_VALUE)
            throw new UnreachableVertexException();
        else return d;
        }
        }

    }