Codota Logo
ValidatorDAG
Code IndexAdd Codota to your IDE (free)

How to use
ValidatorDAG
in
slib.graph.algo.validator.dag

Best Java code snippets using slib.graph.algo.validator.dag.ValidatorDAG (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
DateTime d =
  • Codota Iconnew DateTime()
  • Codota IconDateTimeFormatter formatter;String text;formatter.parseDateTime(text)
  • Codota IconObject instant;new DateTime(instant)
  • Smart code suggestions by Codota
}
origin: com.github.sharispe/slib-graph-algo

  /**
   * Root the underlying taxonomic DAG of the specified graph.
   *
   * @param g 
   * @param rootUri 
   * @return the URI of the root
   * @throws SLIB_Ex_Critic 
   */
  public static URI rootUnderlyingTaxonomicDAG(G g, URI rootUri) throws SLIB_Ex_Critic {

    Logger logger = LoggerFactory.getLogger(RooterDAG.class);
    logger.info("Rooting taxonomic Graph using " + rootUri);
    ValidatorDAG validator = new ValidatorDAG();

    if (!validator.containsTaxonomicDagWithUniqueRoot(g)) {
      return rootUnderlyingDAG(g, rootUri, new WalkConstraintGeneric(RDFS.SUBCLASSOF,Direction.OUT),true);
    } else {
      return validator.getUniqueTaxonomicRoot(g);
    }
  }
}
origin: com.github.sharispe/slib-graph-algo

/**
 * Do not check if the graph is a DAG
 *
 * @param g
 * @param root
 * @param wc
 * @return true if the graph is a DAG and rooted by a unique vertex.
 * @throws SLIB_Ex_Critic
 */
public boolean isUniqueRootedDagRoot(G g, URI root, WalkConstraint wc) throws SLIB_Ex_Critic {
  if (isDag(g, wc)) {
    Set<URI> roots = getDAGRoots(g, WalkConstraintUtils.getInverse(wc, false));
    logger.debug("roots: " + roots);
    if (roots.size() == 1 && roots.iterator().next().equals(root)) {
      return true;
    }
  }
  return false;
}
origin: com.github.sharispe/slib-graph-algo

/**
 * @param g
 * @param root
 * @return true if the graph contains a taxonomic graph which is rooted by a
 * unique vertex.
 * @throws SLIB_Ex_Critic
 */
public boolean isUniqueRootedTaxonomicDag(G g, URI root) throws SLIB_Ex_Critic {
  WalkConstraint wc = new WalkConstraintGeneric(RDFS.SUBCLASSOF, Direction.IN);
  return isUniqueRootedDagRoot(g, root, wc);
}
origin: com.github.sharispe/slib-sml

/**
 * Get the root of the taxonomic graph contained in the graph associated to
 * the engine. An exception will be thrown if the taxonomic graph contains
 * multiple roots.
 *
 * @return the class corresponding to the root.
 * @throws slib.utils.ex.SLIB_Ex_Critic
 */
public synchronized URI getRoot() throws SLIB_Ex_Critic {
  if (root == null) {
    URI rooturi = new ValidatorDAG().getUniqueTaxonomicRoot(graph);
    root = rooturi;
  }
  return root;
}
origin: com.github.sharispe/slib-graph-algo

ValidatorDAG validator = new ValidatorDAG();
if (checkUnderlyingDAG && !validator.isDag(g, wc)) {
  throw new SLIB_Ex_Critic("Error during rerooting: "
      + "Underlying graph build from  contraint " + wc + ""
Set<URI> roots = new ValidatorDAG().getDAGRoots(g, wc);
  logger.debug(" Contains Rooted taxonomic DAG " + validator.containsTaxonomicDagWithUniqueRoot(g));
origin: sharispe/slib

/**
 * Performs a transitive reduction of the underlying taxonomic graph of the
 * given graph. The underlying taxonomic graph is defined based on the
 * rdfs:SubClassOf relationship.
 *
 * @param graph the graph on which the transitive reduction needs to be
 * performed
 * @throws SLIB_Ex_Critic
 * @return the set of edges removed.
 */
public static Set<E> process(G graph) throws SLIB_Ex_Critic {
  logger.info("Processing self-loop");
  // remove self loops
  int selfLoops = 0;
  for (E e : graph.getE(RDFS.SUBCLASSOF)) {
    if (e.getSource().equals(e.getTarget())) {
      graph.removeE(e);
      selfLoops++;
    }
  }
  logger.info(selfLoops + " self loops have been removed");
  ValidatorDAG validator = new ValidatorDAG();
  if (!validator.containsTaxonomicDag(graph)) {
    throw new SLIB_Ex_Critic("Transitive reduction on taxonomic graph requires an underlying DAG to be defined");
  }
  Set<URI> roots = new ValidatorDAG().getTaxonomicRoots(graph);
  logger.info("Transitive reduction considering " + roots.size() + " root(s)");
  logger.debug("roots: " + roots);
  return process(graph, roots);
}
origin: sharispe/slib

/**
 * Get the root of the taxonomic graph contained in the graph associated to
 * the engine. An exception will be thrown if the taxonomic graph contains
 * multiple roots. The result is cached.
 *
 * @return the class corresponding to the root.
 * @throws SLIB_Ex_Critic
 */
public synchronized URI getRoot() throws SLIB_Ex_Critic {
  if (root == null) {
    Set<URI> roots = new ValidatorDAG().getDAGRoots(graph, topNodeAccessor.getWalkConstraint());
    if (roots.size() != 1) {
      throw new SLIB_Ex_Critic("Multiple roots detected in the underlying taxonomic graph of graph " + graph.getURI());
    }
    root = roots.iterator().next();
  }
  return root;
}
origin: sharispe/slib

  private void checkGraphProperties() throws SLIB_Ex_Critic {
    logger.debug("Checking DAG property");

    ValidatorDAG vdag = new ValidatorDAG();

    WalkConstraint wc = new WalkConstraintGeneric();
    for (URI edgeType : predicatesTC) {
      wc.addAcceptedTraversal(edgeType, Direction.IN);
    }

    boolean isDag = vdag.isDag(graph, wc);
    logger.debug("is DAG: " + isDag);

    if (!isDag) {
      throw new SLIB_Ex_Critic(
          "Treatment can only be performed on a DAG, traversal "
          + "respecting your parameters define a cyclic graph.");
    }

//        ValidatorDAG validator = new ValidatorDAG();
//
//        boolean uniqueRoot = validator.isUniqueRootedTaxonomicDag(graph, rootURI);
//
//        if (!uniqueRoot) {
//            logger.info("Specified root is not a unique Root: " + rootVertex);
//            logger.info("Roots : " + validator.getTaxonomicDAGRoots(graph));
//        }
  }
}
origin: com.github.sharispe/slib-graph-algo

/**
 * Return the vertices which root the taxonomic graph.
 *
 * @param g
 * @return the vertices which can be considered as a root, i.e. all the
 * vertices which are not subsumed by an other vertex through a taxonomic
 * relationship.
 */
public Set<URI> getTaxonomicRoots(G g) {
  return getDAGRoots(g, new WalkConstraintGeneric(RDFS.SUBCLASSOF, Direction.OUT));
}
origin: com.github.sharispe/slib-graph-algo

/**
 *
 * @param graph
 * @return true if the graph contains a taxonomic graph.
 * @throws SLIB_Ex_Critic
 */
public boolean containsTaxonomicDag(G graph) throws SLIB_Ex_Critic {
  WalkConstraint wct = new WalkConstraintGeneric(RDFS.SUBCLASSOF, Direction.IN);
  return isDag(graph, wct);
}
origin: sharispe/slib

performDFS(rootUri);
origin: com.github.sharispe/slib-graph-algo

ValidatorDAG validator = new ValidatorDAG();
if (checkUnderlyingDAG && !validator.isDag(g, wc)) {
  throw new SLIB_Ex_Critic("Error during rerooting: "
      + "Underlying graph build from  contraint " + wc + ""
Set<URI> roots = new ValidatorDAG().getDAGRoots(g, wc);
  logger.debug(" Contains Rooted taxonomic DAG " + validator.containsTaxonomicDagWithUniqueRoot(g));
origin: com.github.sharispe/slib-graph-algo

ValidatorDAG validator = new ValidatorDAG();
if (!validator.containsTaxonomicDag(graph)) {
  throw new SLIB_Ex_Critic("Transitive reduction on taxonomic graph requires an underlying DAG to be defined");
Set<URI> roots = new ValidatorDAG().getTaxonomicRoots(graph);
origin: com.github.sharispe/slib-sml

Set<URI> roots = new ValidatorDAG().getDAGRoots(graph, ancGetter.getWalkConstraint());
origin: com.github.sharispe/slib-graph-algo

  private void checkGraphProperties() throws SLIB_Ex_Critic {
    logger.debug("Checking DAG property");

    ValidatorDAG vdag = new ValidatorDAG();

    WalkConstraint wc = new WalkConstraintGeneric();
    for (URI edgeType : predicatesTC) {
      wc.addAcceptedTraversal(edgeType, Direction.IN);
    }

    boolean isDag = vdag.isDag(graph, wc);
    logger.debug("is DAG: " + isDag);

    if (!isDag) {
      throw new SLIB_Ex_Critic(
          "Treatment can only be performed on a DAG, traversal "
          + "respecting your parameters define a cyclic graph.");
    }

//        ValidatorDAG validator = new ValidatorDAG();
//
//        boolean uniqueRoot = validator.isUniqueRootedTaxonomicDag(graph, rootURI);
//
//        if (!uniqueRoot) {
//            logger.info("Specified root is not a unique Root: " + rootVertex);
//            logger.info("Roots : " + validator.getTaxonomicDAGRoots(graph));
//        }
  }
}
origin: sharispe/slib

/**
 * Return the vertices which root the taxonomic graph.
 *
 * @param g
 * @return the vertices which can be considered as a root, i.e. all the
 * vertices which are not subsumed by an other vertex through a taxonomic
 * relationship.
 */
public Set<URI> getTaxonomicRoots(G g) {
  return getDAGRoots(g, new WalkConstraintGeneric(RDFS.SUBCLASSOF, Direction.OUT));
}
origin: sharispe/slib

/**
 *
 * @param graph
 * @return true if the graph contains a taxonomic graph.
 * @throws SLIB_Ex_Critic
 */
public boolean containsTaxonomicDag(G graph) throws SLIB_Ex_Critic {
  WalkConstraint wct = new WalkConstraintGeneric(RDFS.SUBCLASSOF, Direction.IN);
  return isDag(graph, wct);
}
origin: com.github.sharispe/slib-graph-algo

performDFS(rootUri);
origin: sharispe/slib

ValidatorDAG validator = new ValidatorDAG();
if (checkUnderlyingDAG && !validator.isDag(g, wc)) {
  throw new SLIB_Ex_Critic("Error during rerooting: "
      + "Underlying graph build from  contraint " + wc + ""
Set<URI> roots = new ValidatorDAG().getDAGRoots(g, wc);
  logger.debug(" Contains Rooted taxonomic DAG " + validator.containsTaxonomicDagWithUniqueRoot(g));
origin: com.github.sharispe/slib-graph-algo

  /**
   * Root the underlying taxonomic DAG of the specified graph.
   *
   * @param g 
   * @param rootUri 
   * @return the URI of the root
   * @throws SLIB_Ex_Critic 
   */
  public static URI rootUnderlyingTaxonomicDAG(G g, URI rootUri) throws SLIB_Ex_Critic {

    Logger logger = LoggerFactory.getLogger(RooterDAG.class);
    logger.info("Rooting taxonomic Graph using " + rootUri);
    ValidatorDAG validator = new ValidatorDAG();

    if (!validator.containsTaxonomicDagWithUniqueRoot(g)) {
      return rootUnderlyingDAG(g, rootUri, new WalkConstraintGeneric(RDFS.SUBCLASSOF,Direction.OUT),true);
    } else {
      return validator.getUniqueTaxonomicRoot(g);
    }
  }
}
slib.graph.algo.validator.dagValidatorDAG

Javadoc

Used to validate if a graph is directed and acyclic (DAG)

Most used methods

  • <init>
  • getDAGRoots
    Root vertices (terminal vertices) are those of type CLASS which respect the following restrictions :
  • getUniqueTaxonomicRoot
    Return the unique vertex rooting the underlying taxonomic graph. Do not check if the taxonomic graph
  • containsTaxonomicDag
  • containsTaxonomicDagWithUniqueRoot
    Check if the given graph contains a underlying taxonomic graph with a unique root.
  • getTaxonomicRoots
    Return the vertices which root the taxonomic graph.
  • isDag
    Check if the underlying graph defined by given WalkConstraint is a DAG. shortcut of ValidatorDAG#isD
  • isUniqueRootedDagRoot
    Do not check if the graph is a DAG
  • performDFS

Popular in Java

  • Start an intent from android
  • runOnUiThread (Activity)
  • scheduleAtFixedRate (Timer)
  • orElseThrow (Optional)
  • VirtualMachine (com.sun.tools.attach)
    A Java virtual machine. A VirtualMachine represents a Java virtual machine to which this Java vir
  • Kernel (java.awt.image)
  • PrintWriter (java.io)
    Prints formatted representations of objects to a text-output stream. This class implements all of th
  • Dictionary (java.util)
    The Dictionary class is the abstract parent of any class, such as Hashtable, which maps keys to valu
  • NoSuchElementException (java.util)
    Thrown when trying to retrieve an element past the end of an Enumeration or Iterator.
  • TreeSet (java.util)
    A NavigableSet implementation based on a TreeMap. The elements are ordered using their Comparable, o
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now