public static <TARGET_TYPE, CACHE_TYPE extends CachedData<TARGET_TYPE, CACHE_TYPE>>
      void checkDepthLabelling(AbstractLearnerGraph<TARGET_TYPE, CACHE_TYPE> coregraph) {
    int coreGraphStateNumber = coregraph.getStateNumber();
    Map<CmpVertex, Integer> stateToDepth =
        coregraph.config.getTransitionMatrixImplType() == STATETREE.STATETREE_ARRAY
            ? new ArrayMapWithSearch<CmpVertex, Integer>(coreGraphStateNumber)
            : new HashMapWithSearch<CmpVertex, Integer>(coreGraphStateNumber);
    CmpVertex from = coregraph.getInit();
    stateToDepth.put(from, 0);
    Queue<CmpVertex> fringe = new LinkedList<CmpVertex>();
    Map<CmpVertex, CmpVertex> statesInFringe =
        coregraph.config.getTransitionMatrixImplType() == STATETREE.STATETREE_ARRAY
            ? new ArrayMapWithSearch<CmpVertex, CmpVertex>(coreGraphStateNumber)
            : new HashMapWithSearch<CmpVertex, CmpVertex>(
                coreGraphStateNumber); // in order not to iterate through the list all the time.

    fringe.add(from);
    statesInFringe.put(from, from);
    while (!fringe.isEmpty()) {
      CmpVertex currentState = fringe.remove();
      Integer currentDepth = stateToDepth.get(currentState);
      Map<Label, TARGET_TYPE> targets = coregraph.transitionMatrix.get(currentState);
      if (targets != null && !targets.isEmpty())
        for (Entry<Label, TARGET_TYPE> labelstate : targets.entrySet())
          for (CmpVertex target : coregraph.getTargets(labelstate.getValue())) {
            if (!statesInFringe.containsKey(
                target)) // put returns the old value, so if it returned null, it means that target
            // was not already in the list (but it has since been added)
            {
              int newDepth = currentDepth + 1;
              stateToDepth.put(target, newDepth);
              Assert.assertEquals("state " + target, newDepth, target.getDepth());
              fringe.offer(target);
              statesInFringe.put(target, target);
            }
          }
    }
  }