return paths.hasNext() ? paths.next() : null;
}
private Iterator<Path> paths( final Node start, final Node end )
{
TraversalDescription base = Traversal.description().uniqueness(
Uniqueness.RELATIONSHIP_PATH ).order(
new BranchOrderingPolicy()
{
public BranchSelector create( TraversalBranch startSource )
{
return new LiteDepthFirstSelector( startSource,
startThreshold );
}
} );
final int firstHalf = onDepth / 2;
Traverser startTraverser = base.prune(
Traversal.pruneAfterDepth( firstHalf ) ).expand(
expander ).filter( new Predicate<Path>()
{
public boolean accept( Path item )
{
return item.length() == firstHalf;
}
} ).traverse( start );
final int secondHalf = onDepth - firstHalf;
Traverser endTraverser = base.prune(
Traversal.pruneAfterDepth( secondHalf ) ).expand(
expander.reversed() ).filter( new Predicate<Path>()
{
public boolean accept( Path item )
{