Skip to content

Fix the code example #228

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -357,20 +357,20 @@ class MaxWeightPathExpander implements PathExpander<Double>
}

@Override
public Iterable<Relationship> expand( Path path, BranchState<Double> branchState )
public ResourceIterable<Relationship> expand( Path path, BranchState<Double> branchState )
{
if (path.lastRelationship() != null) {
branchState.setState( branchState.getState() + (double) path.lastRelationship().getProperty( "weight" ) );
}

Iterable<Relationship> relationships = path.endNode().getRelationships( Direction.OUTGOING );
ResourceIterable<Relationship> relationships = path.endNode().getRelationships( Direction.OUTGOING );
ArrayList<Relationship> filtered = new ArrayList<>();
for ( Relationship relationship : relationships ) {
if ( branchState.getState() + (double) relationship.getProperty( "weight" ) <= maxWeight ) {
filtered.add(relationship);
}
}
return filtered;
return Iterables.asResourceIterable(filtered);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've accepted the change, though it does use an internal method (Iterables utility class is not part of the public api)
We don't have an alternative currently that I am aware of, other than the user writing their own wrapper.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we have informed customers who do use the traversal framework to use this method in the past.

}

@Override
Expand Down
Loading