code: private int getNumberOfNeighborConnections(int node) {
          int numberOfConnections = 0;
  
          // get the set of neighbors
          Set<Integer> neighbors = getNeighbors(node);
  
          if (neighbors.size() > 0) {
              // for each pair of neighbors, test if there is a connection
              Object[] nodeArray = neighbors.toArray();
              // sort the Array so we can use a simple iteration with two for loops to access all pairs
              Arrays.sort(nodeArray);
  
              for (int i=0; i<neighbors.size(); i++) {
                  int outerNode = (Integer) nodeArray[i];
                  for (int j=i+1; j<neighbors.size(); j++) {
                      int innerNode = (Integer) nodeArray[j];
                      // in case of a connection - increade connection counter
                      // order of the nodes doesn't matter for undirected graphs
                      if (undirectedGraph.containsEdge(innerNode, outerNode)) {
                          numberOfConnections++;
                      }
                  }
              }
          }
  
  //        logger.info(neighbors.size() + " - " + numberOfConnections);
  
          return numberOfConnections;
      }
docs: Get the number of connections that exist between the neighbors of a node.
  @param node The node under consideration.
  @return The number of connections that exist between the neighbors of node.