private static final int MAXIMUM_DEPTH = 5;
public Collection<RatedRestaurant> getTopNRatedRestaurants(final UserAccount user, final int n) {
final CalculateRatingPredicate calculateRatingPredicate = new CalculateRatingPredicate();
final Node userNode=user.getPersistentState();
final TraversalDescription traversalDescription = new TraversalDescriptionImpl()
.order(Traversal.postorderBreadthFirst())
.prune(Traversal.pruneAfterDepth(MAXIMUM_DEPTH))
.filter(calculateRatingPredicate)
.relationships(DynamicRelationshipType.withName("friends"));
final Traverser traverser = traversalDescription.traverse(userNode);
final Iterator<Node> it = traverser.nodes().iterator();
while (it.hasNext()) {
it.next();
}
return calculateRatingPredicate.getRecommendedRestaurants(n);