/** Builds the set of paths between all the couple of vertexes */
  private void buildPaths() {

    logger.debug("IN");

    allGraphPaths = new HashSet<GraphPath<IModelEntity, Relationship>>();
    paths = new HashSet<EntitiesPath>();

    // build all the path between entities
    Iterator<IModelEntity> vertexesIter = entities.iterator();

    // First loop for the source of the path
    while (vertexesIter.hasNext()) {
      IModelEntity startVertex = vertexesIter.next();
      logger.debug("Building the list of path starting from " + startVertex.getName());
      // inner loop for the target of the path
      Iterator<IModelEntity> vertexesInnerIter = entities.iterator();
      while (vertexesInnerIter.hasNext()) {
        IModelEntity endVertex = vertexesInnerIter.next();
        if (!startVertex.equals(endVertex)) {
          EntitiesPath entitiesPath = new EntitiesPath(startVertex, endVertex);
          if (!this.paths.contains(entitiesPath)) {
            logger.debug(
                "Building the list of path between the vertexes ["
                    + startVertex.getName()
                    + ","
                    + endVertex.getName()
                    + "]");
            KShortestPaths<IModelEntity, Relationship> kshortestPath =
                new KShortestPaths<IModelEntity, Relationship>(graph, startVertex, maxPathLength);
            List<GraphPath<IModelEntity, Relationship>> graphPaths =
                kshortestPath.getPaths(endVertex);

            // if there is at least one path between the 2 vertex
            if (graphPaths != null) {
              entitiesPath.setPaths(graphPaths);

              // updating the class variables
              this.paths.add(entitiesPath);
              for (int i = 0; i < graphPaths.size(); i++) {
                GraphPath<IModelEntity, Relationship> path = graphPaths.get(i);
                if (!containsPath(this.allGraphPaths, path)) {
                  this.allGraphPaths.add(path);
                }
              }
            }
          }
        }
      }
    }
    logger.debug("OUT");
  }