/** * 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; }
/** * 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; }
/** * 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); } } }
/** * 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); } } }
/** * 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); } } }
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)); // } } }
/** * 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); } } }
ValidatorDAG validator = new ValidatorDAG(); Set<URI> roots = new ValidatorDAG().getDAGRoots(g, wc);
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)); // } } }
ValidatorDAG validator = new ValidatorDAG(); Set<URI> roots = new ValidatorDAG().getDAGRoots(g, wc);
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)); // } } }
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)); // } } }
ValidatorDAG validator = new ValidatorDAG(); Set<URI> roots = new ValidatorDAG().getDAGRoots(g, wc);
ValidatorDAG validator = new ValidatorDAG(); Set<URI> roots = new ValidatorDAG().getDAGRoots(g, wc);
Set<URI> roots = new ValidatorDAG().getDAGRoots(graph, ancGetter.getWalkConstraint());
/** * 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); }
ValidatorDAG validator = new ValidatorDAG(); Set<URI> roots = new ValidatorDAG().getTaxonomicRoots(graph);
Set<URI> roots = new ValidatorDAG().getDAGRoots(graph, topNodeAccessor.getWalkConstraint());
ValidatorDAG validator = new ValidatorDAG(); Set<URI> roots = new ValidatorDAG().getTaxonomicRoots(graph);
ValidatorDAG validator = new ValidatorDAG(); Set<URI> roots = new ValidatorDAG().getTaxonomicRoots(graph);