public double correlate(Node source, Node target, RelationshipType type, Direction dir, Object... more) { if (null == source) throw new IllegalArgumentException("Illegal 'source' argument in Problem.correlate(Node, Node, RelationshipType, Direction, Object...): " + source); if (null == target) throw new IllegalArgumentException("Illegal 'target' argument in Problem.correlate(Node, Node, RelationshipType, Direction, Object...): " + target); if (null == type) throw new IllegalArgumentException("Illegal 'type' argument in Problem.correlate(Node, Node, RelationshipType, Direction, Object...): " + type); if (null == dir) throw new IllegalArgumentException("Illegal 'dir' argument in Problem.correlate(Node, Node, RelationshipType, Direction, Object...): " + dir); if (source.equals(target)) return 1.0; try (Transaction ignore = graph.beginTx()) { PathExpander<Object> expander = null; if (null == more || 0 == more.length) expander = PathExpanders.forTypeAndDirection(type, dir); else { RelationshipType t = (RelationshipType) more[0]; Direction d = (Direction) more[1]; expander = PathExpanders.forTypesAndDirections(type, dir, t, d, Arrays.copyOfRange(more, 2, more.length)); } PathFinder<Path> finder = GraphAlgoFactory.allPaths(expander, 1 + count); Iterable<Path> paths = finder.findAllPaths(source, target); Set<Relationship> relationships = new HashSet<>(); Set<Set<Relationship>> expression = new HashSet<>(); for (Path path : paths) { Set<Relationship> item = new HashSet<>(); for (Relationship relationship : path.relationships()) { relationships.add(relationship); item.add(relationship); } expression.add(item); } BDD bdd = new BDD(expression, relationships); bdd.dump("bdd.gv"); return bdd.traverse(); } }
@Override public PathExpander reverse() { return null; }
@Override public PathExpander<PrimitiveLongSet> reverse() { throw new UnsupportedOperationException(); }
@Override public PathExpander<Void> reverse() { return null; }
@Override public final PathExpander reverse() { return this; }
@Override public PathExpander<StepState> reverse() { // TODO deal with this in better way throw new UnsupportedOperationException( "reverse not implemented by " + getClass().getSimpleName() ); }
@Override public PathExpander reverse() { throw new UnsupportedOperationException(); }