code: private Stream<ConceptSetMeasure> runComputeCoreness(GraqlCompute.Centrality query) {
          long k = query.where().minK().get();
  
          if (k < 2L) throw GraqlQueryException.kValueSmallerThanTwo();
  
          Set<Label> targetTypeLabels;
  
          // Check if ofType is valid before returning emptyMap
          if (query.of().isEmpty()) {
              targetTypeLabels = scopeTypeLabels(query);
          } else {
              targetTypeLabels = query.of().stream()
                      .flatMap(t -> {
                          Label typeLabel = Label.of(t);
                          Type type = tx.getSchemaConcept(typeLabel);
                          if (type == null) throw GraqlQueryException.labelNotFound(typeLabel);
                          if (type.isRelationType()) throw GraqlQueryException.kCoreOnRelationType(typeLabel);
                          return type.subs();
                      })
                      .map(SchemaConcept::label)
                      .collect(toSet());
          }
  
          Set<Label> scopeTypeLabels = Sets.union(scopeTypeLabels(query), targetTypeLabels);
  
          if (!scopeContainsInstance(query)) {
              return Stream.empty();
          }
  
          ComputerResult result;
          Set<LabelId> scopeTypeLabelIDs = convertLabelsToIds(scopeTypeLabels);
          Set<LabelId> targetTypeLabelIDs = convertLabelsToIds(targetTypeLabels);
  
          try {
              result = compute(new CorenessVertexProgram(k),
                               new DegreeDistributionMapReduce(targetTypeLabelIDs, CorenessVertexProgram.CORENESS),
                               scopeTypeLabelIDs);
          } catch (NoResultException e) {
              return Stream.empty();
          }
  
          Map<Long, Set<ConceptId>> centralityMap = result.memory().get(DegreeDistributionMapReduce.class.getName());
  
          return centralityMap.entrySet().stream()
                  .map(centrality -> new ConceptSetMeasure(centrality.getValue(), centrality.getKey()));
      }
docs: The Graql compute centrality using k-core query run method
  
  @return a Answer containing the centrality count map