/** * Compute the inclusive ancestors for all classes. * * @throws SLIB_Ex_Critic */ private void computeAllclassesAncestors() throws SLIB_Ex_Critic { cache.ancestorsInc = ancGetter.getAllAncestorsInc(); }
/** * Compute the set of exclusive ancestors of all vertices contained in the * graph. Exclusive process: the focused vertex will NOT be included in the * set of ancestors. * * @return a map containing the exclusive set of ancestors of each vertex * concept (empty set if any). * @throws SLIB_Ex_Critic */ public Map<URI, Set<URI>> getAllAncestorsExc() throws SLIB_Ex_Critic { return getAllRV(); }
/** * Compute the set of inclusive ancestors of all vertices contained in the * graph. The focused vertex will be included in the set of ancestors. * * @return a map containing the inclusive set of ancestors of each vertex * concept. * @throws SLIB_Ex_Critic */ public Map<URI, Set<URI>> getAllAncestorsInc() throws SLIB_Ex_Critic { return getAllRVInc(); } }
/** * CACHED ! Be careful modification of RelTypes requires cache clearing * * @param a * @param b * @param weightingScheme * @return the shortest path between the two classes considering the given * weighting scheme. * @throws SLIB_Ex_Critic */ public double getShortestPath(URI a, URI b, GWS weightingScheme) throws SLIB_Ex_Critic { if (cache.shortestPath.get(a) == null || cache.shortestPath.get(a).get(b) == null) { if (cache.shortestPath.get(a) == null) { cache.shortestPath.put(a, new ConcurrentHashMap<URI, Double>()); } WalkConstraint wc = WalkConstraintUtils.copy(ancGetter.getWalkConstraint()); wc.addWalkconstraints(descGetter.getWalkConstraint()); Dijkstra dijkstra = new Dijkstra(graph, wc, weightingScheme); double sp = dijkstra.shortestPath(a, b); cache.shortestPath.get(a).put(b, sp); } return cache.shortestPath.get(a).get(b); }
/** * Compute the set of exclusive ancestors of a class. Exclusive process: the * focused vertex will NOT be included in the set of ancestors. * * @param v the vertex of interest * @return the exclusive set of ancestors of the concept (empty set if any). */ public Set<URI> getAncestorsExc(URI v) { return getRV(v); }
logger.info(g.toString()); ancGetter = new AncestorEngine(graph); descGetter = new DescendantEngine(graph);
/** * Get the parents of a class, that is to say its direct ancestors. * * <br/><b>Important</b>:<br/> * * The direct parent of a class are all classes x linked to the given class * c to a an edge x RDFS.SUBLASSOF c. The result is not cached by the * engine. To ensure result coherency the underlying requires to be * transitively reduced, refer to the class documentation for more * information. * * @param v the focus vertex * @return the set of parents of the given vertex */ public Set<URI> getParents(URI v) { throwErrorIfNotClass(v); Set<URI> parents = graph.getV(v, ancGetter.getWalkConstraint()); return parents; }
/** * Compute the set of exclusive ancestors of a class. Exclusive process: the * focused vertex will NOT be included in the set of ancestors. * * @param v the vertex of interest * @return the exclusive set of ancestors of the concept (empty set if any). */ public Set<URI> getAncestorsExc(URI v) { return getRV(v); }
/** * Constructor of an engine associated to the given graph. The taxonomic * relationship used is rdfs:subClassOf * * Note that the engine expects the graph not to be modified and coherency * of results are only ensured in this case. Please refer to the general * documentation of the class for more information considering this specific * restriction. * * The engine creation is expensive, avoid useless calls to the constructor. * Indeed, some information such as classes and instances of the graph are * computed at engine creation which can lead to performance issues dealing * with large graphs. * * @param g the graph associated to the engine. * @throws SLIB_Ex_Critic */ public SM_Engine(final G g) throws SLIB_Ex_Critic { this.graph = g; topNodeAccessor = new AncestorEngine(graph); bottomNodeAccessor = new DescendantEngine(graph); logger.info("Computing classes..."); classes = GraphAccessor.getClasses(graph); instanceAccessor = new InstanceAccessorTax(graph); initEngine(); }
Set<URI> roots = new ValidatorDAG().getDAGRoots(graph, ancGetter.getWalkConstraint()); DFS dfs = new DFS(graph, roots, WalkConstraintUtils.getInverse(ancGetter.getWalkConstraint(), (false))); List<URI> topoOrdering = dfs.getTraversalOrder(); for (E e : graph.getE(c, ancGetter.getWalkConstraint())) {
/** * Compute the set of inclusive ancestors of a class. The focused vertex * will be included in the set of ancestors. * * @param v the vertex of interest * @return the set composed of the ancestors of the concept + the concept. */ public Set<URI> getAncestorsInc(URI v) { Set<URI> set = getRV(v); set.add(v); return set; }
/** * Compute the set of exclusive ancestors of all vertices contained in the * graph. Exclusive process: the focused vertex will NOT be included in the * set of ancestors. * * @return a map containing the exclusive set of ancestors of each vertex * concept (empty set if any). * @throws SLIB_Ex_Critic */ public Map<URI, Set<URI>> getAllAncestorsExc() throws SLIB_Ex_Critic { return getAllRV(); }
/** * CACHED * * @param a * @param weightingScheme * @return a map containing the weight of the shortest path linking a the * given vertex. * * @throws SLIB_Ex_Critic */ public synchronized Map<URI, Double> getAllShortestPath(URI a, GWS weightingScheme) throws SLIB_Ex_Critic { if (cache.shortestPath.get(a) == null) { WalkConstraint wc = WalkConstraintUtils.copy(ancGetter.getWalkConstraint()); wc.addWalkconstraints(descGetter.getWalkConstraint()); Dijkstra dijkstra = new Dijkstra(graph, wc, weightingScheme); ConcurrentHashMap<URI, Double> minDists_cA = dijkstra.shortestPath(a); cache.shortestPath.put(a, minDists_cA); } return cache.shortestPath.get(a); }
/** * Compute the set of inclusive ancestors of a class. The focused vertex * will be included in the set of ancestors. * * @param v the vertex of interest * @return the set composed of the ancestors of the concept + the concept. */ public Set<URI> getAncestorsInc(URI v) { Set<URI> set = getRV(v); set.add(v); return set; }
/** * Compute the set of inclusive ancestors of all vertices contained in the * graph. The focused vertex will be included in the set of ancestors. * * @return a map containing the inclusive set of ancestors of each vertex * concept. * @throws SLIB_Ex_Critic */ public Map<URI, Set<URI>> getAllAncestorsInc() throws SLIB_Ex_Critic { Map<URI, Set<URI>> allAncs = getAllRV(); for (URI v : allAncs.keySet()) { allAncs.get(v).add(v); } return allAncs; } }
/** * NOT_CACHED * * @param a * @param b * @param weightingScheme * @return the URI associated to the Most Specific Ancestor. * @throws SLIB_Ex_Critic */ public URI getMSA(URI a, URI b, GWS weightingScheme) throws SLIB_Ex_Critic { Dijkstra dijkstra = new Dijkstra(graph, ancGetter.getWalkConstraint(), weightingScheme); URI msa_pk = SimDagEdgeUtils.getMSA_pekar_staab(getRoot(), getAllShortestPath(a, weightingScheme), getAllShortestPath(b, weightingScheme), getAncestorsInc(a), getAncestorsInc(b), dijkstra); return msa_pk; }