/** * 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; }
/** * 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); }
/** * 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; }
/** * 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(topNodeAccessor.getWalkConstraint()); wc.addWalkconstraints(bottomNodeAccessor.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); }
/** * 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; }
/** * 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); }
/** * 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; }
/** * 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(topNodeAccessor.getWalkConstraint()); wc.addWalkconstraints(bottomNodeAccessor.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); }
Set<URI> startingNodes = getDAGRoots(graph, WalkConstraintUtils.getInverse(wc, false));
Set<URI> startingNodes = getDAGRoots(graph, WalkConstraintUtils.getInverse(wc, false));
Set<URI> startingNodes = getDAGRoots(graph, WalkConstraintUtils.getInverse(wc, false));
/** * Check if the underlying graph defined by given {@link WalkConstraint} is * a DAG. shortcut of {@link ValidatorDAG#isDag(G, WalkConstraint)} * considering the given edge types and the root vertices according to the * inverse of the specified edge types as root (see * {@link ValidatorDAG#getDAGRoots(G, WalkConstraint)}) * * @param graph the graph on which the evaluation has to be made * @param wc * @return true if the the (underlying) graph reduction is a DAG * * @throws SLIB_Ex_Critic */ public boolean isDag(G graph, WalkConstraint wc) throws SLIB_Ex_Critic { logger.debug("Check DAG property of the graph " + graph.getURI() + " considering the walkconstraint " + wc); Set<URI> startingNodes = getDAGRoots(graph, WalkConstraintUtils.getInverse(wc, false)); boolean isDag = false; logger.info("Starting process from " + startingNodes.size() + " vertices"); if (graph.getE().isEmpty()) { logger.info("No edge"); isDag = false; } else if (startingNodes.isEmpty()) { // No root No Dag logger.debug("No roots have been detected..."); logger.debug("DAG = false"); isDag = false; } else { isDag = isDag(graph, startingNodes, wc); } return isDag; }
WalkConstraint wcOpp = WalkConstraintUtils.getInverse(wc, false); logger.debug("Building initial queue considering inverse constraint " + wcOpp);
WalkConstraint wcOpp = WalkConstraintUtils.getInverse(wc, false); logger.debug("Building initial queue considering inverse constraint " + wcOpp);
WalkConstraint wcOpp = WalkConstraintUtils.getInverse(wc, false); logger.debug("Building initial queue considering inverse constraint " + wcOpp);
WalkConstraint wcOpp = WalkConstraintUtils.getInverse(wc, false); logger.debug("Building initial queue considering inverse constraint " + wcOpp);
DFS dfs = new DFS(graph, roots, WalkConstraintUtils.getInverse(ancGetter.getWalkConstraint(), (false))); List<URI> topoOrdering = dfs.getTraversalOrder();
WalkConstraint oppositeWC = WalkConstraintUtils.getInverse(wc, false); logger.debug("Opposite Walk constraint " + oppositeWC);
WalkConstraint oppositeWC = WalkConstraintUtils.getInverse(wc, false); logger.debug("Opposite Walk constraint " + oppositeWC);
DFS dfs = new DFS(graph, roots, WalkConstraintUtils.getInverse(topNodeAccessor.getWalkConstraint(), (false))); List<URI> topoOrdering = dfs.getTraversalOrder();