public static ExtendedIterator predicatesFor(Graph g, Node s, Node o) { Set predicates = CollectionFactory.createHashedSet(); ClosableIterator it = g.find(s, Node.ANY, o); while (it.hasNext()) predicates.add(((Triple) it.next()).getPredicate()); return WrappedIterator.createNoRemove(predicates.iterator()); }
public static ExtendedIterator subjectsFor(Graph g, Node p, Node o) { Set objects = CollectionFactory.createHashedSet(); ClosableIterator it = g.find(Node.ANY, p, o); while (it.hasNext()) objects.add(((Triple) it.next()).getSubject()); return WrappedIterator.createNoRemove(objects.iterator()); }