private void computeLeaves() { classesLeaves = new HashSet<URI>(); WalkConstraint wc = descGetter.getWalkConstraint(); for (URI v : classes) { if (graph.getV(v, wc).isEmpty()) { classesLeaves.add(v); } } }
/** * Give access to a view of the maximal depth of all classes. The result is * stored by the engine. * * @return a resultStack containing the maximal depths for all classes * @throws SLIB_Ex_Critic */ public Map<URI, Integer> getMaxDepths() throws SLIB_Ex_Critic { if (cache.maxDepths == null) { DepthAnalyserAG dephtAnalyser = new DepthAnalyserAG(graph, descGetter.getWalkConstraint()); cache.maxDepths = dephtAnalyser.getVMaxDepths(); } return Collections.unmodifiableMap(cache.maxDepths); }
/** * Give access to a view of the minimal depth of all classes. The result is * stored by the engine. * * @return a resultStack containing the maximal depths for all classes * @throws SLIB_Ex_Critic */ public Map<URI, Integer> getMinDepths() throws SLIB_Ex_Critic { if (cache.minDepths == null) { DepthAnalyserAG dephtAnalyser = new DepthAnalyserAG(graph, descGetter.getWalkConstraint()); cache.minDepths = dephtAnalyser.getVMinDepths(); } return Collections.unmodifiableMap(cache.minDepths); }
/** * 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); }
/** * 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); }