/** * Assumes edge contains an index */ public static <T> List<T> getParents(DirectedGraph g, T n) { List<IndexedEdge> incoming = new ArrayList(g.incomingEdgesOf(n)); Collections.sort(incoming); List<T> ret = new ArrayList(); for(IndexedEdge e: incoming) { ret.add((T)e.source); } return ret; }
/** * Returns a set of all edges incoming into the specified vertex. * * @param stateVertix * the state vertix. * @return a set of the incoming edges (clickables) of the stateVertix. * @see org.jgrapht.DirectedGraph#incomingEdgesOf(Object) */ public Set<Eventable> getIncomingClickable(StateVertex stateVertix) { return sfg.incomingEdgesOf(stateVertix); }
public Set<DirectedEdge<ExecutableMethod>> incomingEdgesOf(ExecutableMethod arg0) { return graph.incomingEdgesOf(arg0); } public int outDegreeOf(ExecutableMethod arg0) {
public Set<DirectedEdge<ExecutableMethod>> incomingEdgesOf(ExecutableMethod arg0) { return graph.incomingEdgesOf(arg0); } public int outDegreeOf(ExecutableMethod arg0) {
/** * Assumes edge contains an index */ public static <T> List<T> getParents(DirectedGraph g, T n) { List<IndexedEdge> incoming = new ArrayList(g.incomingEdgesOf(n)); Collections.sort(incoming); List<T> ret = new ArrayList(); for(IndexedEdge e: incoming) { ret.add((T)e.source); } return ret; }
/** * <p>incomingEdgesOf</p> * * @param node a V object. * @return a {@link java.util.Set} object. */ public Set<E> incomingEdgesOf(V node) { if (!containsVertex(node)) // should this just return null? throw new IllegalArgumentException("node not contained in this graph "); // TODO hash set? can't be sure E implements hash correctly return new LinkedHashSet<E>(graph.incomingEdgesOf(node)); }
/** * Fetch all of the dependents of the given target vertex * @return mutable snapshot of the source vertices of all incoming edges */ public static <V> Set<V> getIncomingVertices(DirectedGraph<V, DefaultEdge> graph, V target) { Set<DefaultEdge> edges = graph.incomingEdgesOf(target); Set<V> sources = new LinkedHashSet<V>(); for (DefaultEdge edge : edges) { sources.add(graph.getEdgeSource(edge)); } return sources; }
/** * @param pageID The pageID of the category. * @return A set of parent nodes of the given category. */ protected Set<Integer> __getParents(int pageID) { Set<DefaultEdge> incomingEdges = graph.incomingEdgesOf(pageID); Set<Integer> inLinks = new HashSet<Integer>(); for (DefaultEdge edge : incomingEdges) { inLinks.add(graph.getEdgeSource(edge)); } return inLinks; }
public static Set<LabeledLink> getDomainLinksInDefaultGraph(DirectedGraph<Node, DefaultLink> g, ColumnNode n) { Set<LabeledLink> domainLinks = new HashSet<>(); if (g == null || n == null || !g.vertexSet().contains(n)) return domainLinks; Set<DefaultLink> incomingLinks = g.incomingEdgesOf(n); if (incomingLinks != null) { for (DefaultLink l : incomingLinks) { if (l instanceof LabeledLink) domainLinks.add((LabeledLink)l); } } return domainLinks; }
public static Set<LabeledLink> getDomainLinksInLabeledGraph(DirectedGraph<Node, LabeledLink> g, ColumnNode n) { Set<LabeledLink> domainLinks = new HashSet<>(); if (g == null || n == null || !g.vertexSet().contains(n)) return domainLinks; Set<LabeledLink> incomingLinks = g.incomingEdgesOf(n); if (incomingLinks != null) { for (DefaultLink l : incomingLinks) { domainLinks.add((LabeledLink)l); } } return domainLinks; }
/** * Gives all the rules that depends on the input <code>rule</code> * @param rule * @return */ public List<CQIE> getFatherRules(CQIE rule){ Set<DefaultEdge> fatherEdges = ruleDependencyGraph.incomingEdgesOf(rule); List<CQIE> fatherRules = Lists.newArrayListWithCapacity(fatherEdges.size()); for(DefaultEdge edge : fatherEdges){ fatherRules.add(ruleDependencyGraph.getEdgeSource(edge)); } return fatherRules; }
/** * Gives you the predicate that is defined using <code>pred</code> * @param pred * @return */ public List<Predicate> getFatherPredicates(Predicate pred){ Set<DefaultEdge> fatherEdges = predicateDependencyGraph.incomingEdgesOf(pred); List<Predicate> fathers = new LinkedList<Predicate>(); for (DefaultEdge fatherEdge: fatherEdges){ Predicate father = predicateDependencyGraph.getEdgeSource(fatherEdge); fathers.add(father); } //= fatherEdges.iterator().next(); return fathers; }
public static Set<Node> getInNeighbors(DirectedGraph<Node, DefaultLink> g, Node n) { Set<Node> neighbors = new HashSet<>(); if (g == null || n == null || !g.vertexSet().contains(n)) return neighbors; Set<DefaultLink> incomingLinks = g.incomingEdgesOf(n); if (incomingLinks != null) { for (DefaultLink l : incomingLinks) { neighbors.add(l.getSource()); } } return neighbors; }
public static <T> SetIterable<T> getDependencyNodes(final DirectedGraph<T, DefaultEdge> graph, T vertex) { return SetAdapter.adapt(graph.incomingEdgesOf(vertex)).collect(new Function<DefaultEdge, T>() { @Override public T valueOf(DefaultEdge e) { return graph.getEdgeSource(e); } }); }
public static <T, E> SetIterable<Pair<T, E>> getDependencyNodesAndEdges(final DirectedGraph<T, E> graph, T vertex) { return SetAdapter.adapt(graph.incomingEdgesOf(vertex)).collect(new Function<E, Pair<T, E>>() { @Override public Pair<T, E> valueOf(E edge) { return Tuples.pair(graph.getEdgeSource(edge), edge); } }); }
public static <T> SetIterable<T> getDependencyNodes(final DirectedGraph<T, DefaultEdge> graph, T vertex) { return SetAdapter.adapt(graph.incomingEdgesOf(vertex)).collect(new Function<DefaultEdge, T>() { @Override public T valueOf(DefaultEdge e) { return graph.getEdgeSource(e); } }); }
public static <T, E> SetIterable<Pair<T, E>> getDependencyNodesAndEdges(final DirectedGraph<T, E> graph, T vertex) { return SetAdapter.adapt(graph.incomingEdgesOf(vertex)).collect(new Function<E, Pair<T, E>>() { @Override public Pair<T, E> valueOf(E edge) { return Tuples.pair(graph.getEdgeSource(edge), edge); } }); }
private void collapseCycle(Set<ATermAppl> scc) { Iterator<ATermAppl> i = scc.iterator(); ATermAppl rep = i.next(); while( i.hasNext() ) { ATermAppl node = i.next(); addEquivalent( rep, node ); for( DefaultEdge edge : graph.incomingEdgesOf( node ) ) { ATermAppl incoming = graph.getEdgeSource( edge ); if( !incoming.equals( rep ) ) graph.addEdge( incoming, rep ); } for( DefaultEdge edge : graph.outgoingEdgesOf( node ) ) { ATermAppl outgoing = graph.getEdgeTarget( edge ); if( !outgoing.equals( rep ) ) graph.addEdge( rep, outgoing ); } graph.removeVertex( node ); } }
public static HashMap<SemanticType, LabeledLink> getDomainLinks(DirectedGraph<Node, DefaultLink> g, ColumnNode n, List<SemanticType> semanticTypes) { HashMap<SemanticType, LabeledLink> domainLinks = new HashMap<>(); if (g == null || n == null || semanticTypes == null || !g.vertexSet().contains(n)) return domainLinks; Set<DefaultLink> incomingLinks = g.incomingEdgesOf(n); if (incomingLinks != null) { for (SemanticType st : semanticTypes) { for (DefaultLink l : incomingLinks) { if (st.getDomain().getUri().equalsIgnoreCase(l.getSource().getUri()) && st.getType().getUri().equalsIgnoreCase(l.getUri())) { if (l instanceof LabeledLink) domainLinks.put(st, (LabeledLink)l); } } } } return domainLinks; }
private <T> Map<T, SemanticIndexRange> createSemanticIndex(EquivalencesDAG<T> dag) { DirectedGraph<T, DefaultEdge> namedDag = getNamedDAG(dag); // reverse the named dag so that we give smallest indexes to ? DirectedGraph<T, DefaultEdge> reversed = new EdgeReversedGraph<>(namedDag); LinkedList<T> roots = new LinkedList<>(); for (T n : reversed.vertexSet()) if ((reversed.incomingEdgesOf(n)).isEmpty()) roots.add(n); Map<T,SemanticIndexRange> ranges = new HashMap<>(); for (T root: roots) { // depth-first sort GraphIterator<T, DefaultEdge> orderIterator = new DepthFirstIterator<>(reversed, root); // add Listener to create the ranges orderIterator.addTraversalListener(new SemanticIndexer<T>(reversed, ranges)); // System.out.println("\nIndexing:"); while (orderIterator.hasNext()) orderIterator.next(); } return ranges; }