/// <summary> /// A simple recommendation algorithm that starts from a "user" and examines movies the user has seen filtered by /// the {@code minRating} which removes movies that hold a rating lower than the value specified. It then samples /// the actors in the movies the user has seen and uses that to find other movies those actors have been in that /// the user has not yet seen. Those movies are grouped, counted and sorted based on that count to produce the /// recommendation. /// </summary> public static GraphTraversal <Vertex, Vertex> Recommend(this GraphTraversal <Vertex, Vertex> t, int recommendations, int minRating, Recommender recommender, GraphTraversal <object, object> include) { if (recommendations <= 0) { throw new ArgumentException("recommendations must be greater than zero"); } return(t.Rated(minRating, 0). Aggregate("seen"). Local <List <Vertex> >(RecommenderLookup.Traversals[recommender]). Unfold <Vertex>().In(EdgeActor). Where(Without(new List <string> { "seen" })). Where(include). GroupCount <Vertex>(). Order(Local). By(Values, Decr). Limit <IDictionary <Vertex, long> >(Local, recommendations). Select <Vertex>(Keys). Unfold <Vertex>()); }