private LinkedList<Vertex> convertToRealPath(LinkedList<Vertex> path) {

    LinkedList<Vertex> finalPath = new LinkedList<Vertex>();

    for (int i = 0; i < path.size() - 1; i++) {

      LinkedList<Vertex> temp =
          allPairsShortestPath.getPath(path.get(i).getName(), path.get(i + 1).getName());
      finalPath.addAll(temp);
    }

    for (int j = 0; j < finalPath.size() - 1; j++) {

      Vertex current = finalPath.get(j);
      Vertex next = finalPath.get(j + 1);

      if (current.equals(next)) {

        finalPath.remove(j);
      }
    }

    return finalPath;
  }