/** @throws SLIB_Ex_Critic */
  @Test
  public void test_dag_ancestors_1b() throws SLIB_Ex_Critic {

    RVF_TAX rvf_loc = new RVF_TAX(g, Direction.OUT);
    Map<URI, Set<URI>> ancestorsMap = rvf_loc.getAllRVClass();

    Set<URI> anc = ancestorsMap.get(testValues.G_BASIC_OBJECT);
    System.out.println(anc.size() + "\t" + anc);

    assertTrue(anc.size() == 1);
  }
Esempio n. 2
0
  private static void transitive_reductionInstance(GAction action, G g) throws SLIB_Ex_Critic {

    int invalidInstanceNb = 0;
    int annotNbBase = 0;
    int annotDeleted = 0;

    Set<URI> instances = GraphAccessor.getInstances(g);

    logger.info("Cleaning " + RDF.TYPE + " triplets of " + g.getURI());
    System.out.println(g);

    RVF_TAX rvf = new RVF_TAX(g, Direction.IN);

    // Retrieve descendants for all vertices
    Map<URI, Set<URI>> descs = rvf.getAllRVClass();

    for (URI instance : instances) {

      Set<URI> redundants = new HashSet<URI>();
      Set<URI> classes = g.getV(instance, RDF.TYPE, Direction.OUT);

      annotNbBase += classes.size();

      Iterator<URI> it = classes.iterator();
      while (it.hasNext()) {

        URI c = it.next();
        Set<URI> descC = descs.get(c);

        for (URI c2 : classes) {

          if (c != c2 && descC.contains(c2)) {
            redundants.add(c);
            it.remove();
            break;
          }
        }
      }

      if (!redundants.isEmpty()) {

        for (URI r : redundants) {
          g.removeE(new Edge(instance, RDF.TYPE, r));
        }
        invalidInstanceNb++;
        annotDeleted += redundants.size();
      }
    }

    double invalidInstanceP = 0;
    if (instances.size() > 0) {
      invalidInstanceP = invalidInstanceNb * 100 / instances.size();
    }

    double annotDelP = 0;
    if (annotNbBase > 0) {
      annotDelP = annotDeleted * 100 / annotNbBase;
    }

    logger.info(
        "Number of instance containing abnormal annotation: "
            + invalidInstanceNb
            + "/"
            + instances.size()
            + "  i.e. ("
            + invalidInstanceP
            + "%)");
    logger.info(
        "Number of annotations: "
            + annotNbBase
            + ", deleted: "
            + annotDeleted
            + " ("
            + (annotDelP)
            + "%), current annotation number "
            + (annotNbBase - annotDeleted));
  }