@Override public Node endNode() { return path.endNode(); }
@Override protected Node convert( Path path ) { return path.endNode(); } };
@Override boolean exclude( Path path ) { return !predicate.test( path.endNode() ); } }
public ExtendedPath( Path start, Relationship lastRelationship ) { this.start = start; this.lastRelationship = lastRelationship; this.endNode = lastRelationship.getOtherNode( start.endNode() ); }
@Override long getId( Path source ) { return source.endNode().getId(); }
@Override public NodeValue endNode() { return ValueUtils.fromNodeProxy( path.endNode() ); }
@Override protected Node underlyingObjectToObject( Path path ) { return path.endNode(); } };
@Override ResourceIterator<Relationship> doExpand( Path path, BranchState state ) { return asResourceIterator( path.endNode().getRelationships( direction ).iterator() ); }
@Mapping( "end" ) public ValueRepresentation endNode() { return ValueRepresentation.uri( NodeRepresentation.path( path.endNode() ) ); }
private Direction getDirectionOfLastRelationship( Path path ) { assert path.length() > 0; Direction direction = Direction.INCOMING; if ( path.endNode().equals( path.lastRelationship().getEndNode() ) ) { direction = Direction.OUTGOING; } return direction; } };
@Override ResourceIterator<Relationship> doExpand( Path path, BranchState state ) { final Node node = path.endNode(); ResourceIterator<Relationship> resourceIterator = asResourceIterator( node.getRelationships().iterator() ); return newResourceIterator( new FilteringIterator<>( resourceIterator, rel -> { Exclusion exclude = exclusion.get( rel.getType().name() ); exclude = (exclude == null) ? defaultExclusion : exclude; return exclude.accept( node, rel ); } ), resourceIterator ); }
@Override public Iterable<Relationship> expand( Path path, BranchState<Integer> state ) { if ( path.length() > 0 ) { int newState = state.getState() + ((Number)path.lastRelationship().getProperty( "weight" )).intValue(); state.setState( newState ); encounteredState.put( path.endNode(), newState ); } return path.endNode().getRelationships(); }
@Override public Iterable<Relationship> expand( Path path, BranchState<Double> state ) { double newState = state.getState(); if ( path.length() > 0 ) { newState += (Double) path.lastRelationship().getProperty( "length" ); state.setState( newState ); } seenBranchStates.put( path.endNode(), newState ); return path.endNode().getRelationships( OUTGOING ); }
@Override public Iterable<Relationship> expand( Path path, BranchState<Integer> state ) { state.setState( state.getState() + 1 ); return path.endNode().getRelationships( OUTGOING ); }
@Override public Iterable<Relationship> expand( Path path, BranchState<Integer> state ) { assertEquals( path.length(), state.getState().intValue() ); state.setState( state.getState() + 1 ); return path.endNode().getRelationships( Direction.OUTGOING ); }
@Override @SuppressWarnings( "unchecked" ) public Iterable<Relationship> expand( Path path, BranchState<Object> state ) { if ( path.startNode().equals( path.endNode() ) ) { assertEquals( "Path length must be zero", 0, path.length() ); } else { assertTrue( "Path length must be positive", path.length() > 0 ); } return expander.expand( path, state ); }
@Override public Iterable<Relationship> expand( Path path, BranchState<Integer> state ) { assertEquals( path.length() / 2, state.getState().intValue() ); if ( path.length() % 2 == 1 ) { state.setState( state.getState() + 1 ); } return path.endNode().getRelationships( Direction.OUTGOING ); }
@Test public void testNarrowingFilters() { Evaluator mustBeConnectedToK = new MustBeConnectedToNodeFilter( getNodeWithName( "k" ) ); Evaluator mustNotHaveMoreThanTwoOutRels = path -> Evaluation.ofIncludes( Iterables .count( path.endNode().getRelationships( Direction.OUTGOING ) ) <= 2 ); TraversalDescription description = getGraphDb().traversalDescription().evaluator( mustBeConnectedToK ); expectNodes( description.traverse( node( "a" ) ), "b", "c" ); expectNodes( description.evaluator( mustNotHaveMoreThanTwoOutRels ).traverse( node( "a" ) ), "c" ); }