code: private int getArticlesWithOverlappingCategories(Wikipedia pWiki, CategoryGraph pGraph) throws WikiPageNotFoundException {
          Set<Integer> overlappingArticles = new HashSet<Integer>();
  
          // iterate over all node pairs
          Set<Integer> nodes = pGraph.getGraph().vertexSet();
  
          Map<Integer,Set<Integer>> categoryArticleMap = getCategoryArticleMap(pWiki, nodes);
  
          // sort the Array so we can use a simple iteration with two for loops to access all pairs
          Object[] nodeArray = nodes.toArray();
          Arrays.sort(nodeArray);
  
          int progress = 0;
          for (int i=0; i<nodes.size(); i++) {
              progress++;
              ApiUtilities.printProgressInfo(progress, nodes.size(), 100, ApiUtilities.ProgressInfoMode.TEXT, "");
  
              int outerNode = (Integer) nodeArray[i];
  
              for (int j=i+1; j<nodes.size(); j++) {
                  int innerNode = (Integer) nodeArray[j];
  
                  // test whether the categories have pages in common
                  Set<Integer> outerPages = categoryArticleMap.get(outerNode);
                  Set<Integer> innerPages = categoryArticleMap.get(innerNode);
  
                  for (int outerPage : outerPages) {
                      if (innerPages.contains(outerPage)) {
                          if (!overlappingArticles.contains(outerPage)) {
                              overlappingArticles.add(outerPage);
                          }
                      }
                  }
  
              }
          }
  
          return overlappingArticles.size();
      }
docs: Articles in wikipedia may be tagged with multiple categories.
  It may be interesting to know how many articles have at least one category in common.
  Such articles would have a very high semantic relatedness even if they share a quite secondary category.
  @param pWiki The wikipedia object.
  @param pGraph The category graph.
  @return The number of articles that have at least one category in common.
  @throws WikiPageNotFoundException