/// <summary> /// Traverses from a "user" to a "movie" over the "rated" edge, filtering those edges as specified. If both /// arguments are zero then there is no rating filter. /// </summary> public static GraphTraversal <Vertex, Vertex> Rated(this GraphTraversal <Vertex, Vertex> t, int min, int max) { if (min < 0 || max > 10) { throw new ArgumentException("min must be a value between 0 and 10"); } if (max < 0 || max > 10) { throw new ArgumentException("min must be a value between 0 and 10"); } if (min != 0 && max != 0 && min > max) { throw new ArgumentException("min cannot be greater than max"); } if (min == 0 && max == 0) { return(t.Out(EdgeRated)); } else if (min == 0) { return(t.OutE(EdgeRated).Has(KeyRating, Gt(min)).InV()); } else if (max == 0) { return(t.OutE(EdgeRated).Has(KeyRating, Lt(min)).InV()); } else { return(t.OutE(EdgeRated).Has(KeyRating, Between(min, max)).InV()); } }
/// <summary> /// Assumes a "movie" vertex and traverses to a "genre" vertex with a filter on the name of the genre. This step is meant /// to be used as part of a <code>filter()</code> step for movies. /// </summary> public static GraphTraversal <Vertex, Vertex> Genre(this GraphTraversal <Vertex, Vertex> t, Genre genre, params Genre[] additionalGenres) { var genres = new List <string>(); genres.Add(GenreLookup.Names[genre]); foreach (Genre current in additionalGenres) { genres.Add(GenreLookup.Names[current]); } if (genres.Count < 1) { throw new ArgumentException("There must be at least one genre option provided"); } if (genres.Count == 1) { return(t.Out(EdgeBelongsTo).Has(KeyName, genres[0])); } else { return(t.Out(EdgeBelongsTo).Has(KeyName, Within(genres))); } }
public static GraphTraversal <Vertex, int> YoungestFriendsAge(this GraphTraversal <Vertex, Vertex> t) { return(t.Out("knows").HasLabel("person").Values <int>("age").Min <int>()); }
public static GraphTraversal <Vertex, Vertex> Knows(this GraphTraversal <Vertex, Vertex> t, string personName) { return(t.Out("knows").HasLabel("person").Has("name", personName)); }
public static GraphTraversal <Vertex, Vertex> WorkedOn(this GraphTraversal <Vertex, Vertex> traversal, string appName) => traversal.Out(EdgeNames.WorkedOn) .HasLabel(VertexNames.App) .Has(Properties.Name, appName);
public static GraphTraversal <Vertex, Vertex> AssignedTo(this GraphTraversal <Vertex, Vertex> traversal, string appName) => traversal.Out(EdgeNames.AssignedTo) .HasLabel(VertexNames.App) .Has(Properties.Name, appName);
/// <summary> /// Traverses from a "movie" to an "person" over the "actor" edge. /// </summary> public static GraphTraversal <Vertex, Vertex> Actors(this GraphTraversal <Vertex, Vertex> t) { return(t.Out(EdgeActor).HasLabel(VertexPerson)); }