示例#1
0
        public void VerticesRepeatOutTimes2Emit()
        {
            using (GraphViewCommand command = new GraphViewCommand(graphConnection))
            {
                GraphTraversal2 traversal = command.g().V().Repeat(GraphTraversal2.__().Out()).Times(2).Emit();

                List <string>             results = traversal.Values("name").Next();
                Dictionary <string, long> map     = new Dictionary <string, long>();
                foreach (string name in results)
                {
                    long count;
                    map.TryGetValue(name, out count);
                    map[name] = count + 1;
                }

                Assert.AreEqual(4, map.Count);
                Assert.IsTrue(map.ContainsKey("vadas"));
                Assert.IsTrue(map.ContainsKey("josh"));
                Assert.IsTrue(map.ContainsKey("ripple"));
                Assert.IsTrue(map.ContainsKey("lop"));
                Assert.AreEqual(1, map["vadas"]);
                Assert.AreEqual(1, map["josh"]);
                Assert.AreEqual(2, map["ripple"]);
                Assert.AreEqual(4, map["lop"]);
            }
        }
示例#2
0
        public void HasNameMarko()
        {
            using (GraphViewCommand command = new GraphViewCommand(graphConnection))
            {
                GraphTraversal2 traversal = command.g().V().Has("name", "marko");

                List <string> result = traversal.Values("name").Next();
                Assert.AreEqual(1, result.Count);
                Assert.AreEqual("marko", result.FirstOrDefault());
            }
        }
示例#3
0
        public void VIdOutCreatedInCreatedRange1_3()
        {
            using (GraphViewCommand graphCommand = new GraphViewCommand(graphConnection))
            {
                string vertexId = this.ConvertToVertexId(graphCommand, "marko");
                GraphTraversal2 traversal = graphCommand.g().V().HasId(vertexId).Out("created").In("created").Range(1, 3);

                List<string> results = traversal.Values("name").Next();
                Assert.AreEqual(2, results.Count);
                Assert.AreEqual(true, string.Equals(results.FirstOrDefault(), "marko") || string.Equals(results.FirstOrDefault(), "josh") || string.Equals(results.FirstOrDefault(), "peter"));
            }
        }
示例#4
0
        public void HasVIdHasName()
        {
            using (GraphViewCommand command = new GraphViewCommand(graphConnection))
            {
                string          vertexId  = this.ConvertToVertexId(command, "marko");
                GraphTraversal2 traversal = command.g().V().HasId(vertexId).Has("name");

                List <string> result = traversal.Values("name").Next();
                Assert.AreEqual(1, result.Count);
                Assert.AreEqual("marko", result.FirstOrDefault());
            }
        }
示例#5
0
        public void VIdOutKnowsOutCreatedRange0_1()
        {
            using (GraphViewCommand graphCommand = new GraphViewCommand(graphConnection))
            {
                string vertexId = this.ConvertToVertexId(graphCommand, "marko");
                GraphTraversal2 traversal = graphCommand.g().V().HasId(vertexId).Out("knows").Out("created").Range(0, 1);

                List<string> results = traversal.Values("name").Next();
                Assert.AreEqual(1, results.Count);
                Assert.AreEqual(true, string.Equals(results.FirstOrDefault(), "lop") || string.Equals(results.FirstOrDefault(), "ripple"));
            }
        }
示例#6
0
        public void InHasIdNEQVId()
        {
            using (GraphViewCommand command = new GraphViewCommand(graphConnection))
            {
                string vertexId = this.ConvertToVertexId(command, "marko");

                GraphTraversal2 traversal = command.g().V().In().Has("id", Predicate.neq(vertexId));
                List <string>   result    = traversal.Values("name").Next();

                Assert.AreEqual(3, result.Count);
                Assert.IsTrue(result.Contains("josh") && result.Contains("peter"));
            }
        }
示例#7
0
        public void VerticesRepeatOutTimes2()
        {
            using (GraphViewCommand command = new GraphViewCommand(graphConnection))
            {
                GraphTraversal2 traversal = command.g().V().Repeat(GraphTraversal2.__().Out()).Times(2);

                List <string> results = traversal.Values("name").Next();
                foreach (string name in results)
                {
                    Assert.IsTrue(string.Equals(name, "lop") || string.Equals(name, "ripple"));
                }
                Assert.AreEqual(2, results.Count);
            }
        }
示例#8
0
        public void HasAgeIsGT30()
        {
            using (GraphViewCommand command = new GraphViewCommand(graphConnection))
            {
                GraphTraversal2 traversal = command.g().V().Has("age", GraphTraversal2.__().Is(Predicate.gt(30)));

                List <string> result = traversal.Values("age").Next();
                Assert.AreEqual(2, result.Count);
                foreach (string age in result)
                {
                    Assert.IsTrue(int.Parse(age) > 30);
                }
            }
        }
示例#9
0
        public void VerticesAsHereOutValuesNameSelectHere()
        {
            using (GraphViewCommand command = new GraphViewCommand(graphConnection))
            {
                GraphTraversal2 traversal = command.g().V().As("here").Out().Values("name").Select("here");

                // NOTE: actual tests for complete vertice, but here we just validate that the names are correct. We can do so since the names are unique.
                List <string> result         = traversal.Values("name").Next();
                List <string> expectedResult = new List <string> {
                    "marko", "marko", "marko", "josh", "josh", "peter"
                };
                CheckUnOrderedResults(expectedResult, result);
            }
        }
示例#10
0
        public void HasVertexIdOutAggregateXOutWhereNotWithinX()
        {
            using (GraphViewCommand graphCommand = new GraphViewCommand(graphConnection))
            {
                string markoVertexId = this.ConvertToVertexId(graphCommand, "marko");

                GraphTraversal2 traversal = graphCommand.g().V().HasId(markoVertexId).Out()
                                            .Aggregate("x").Out()
                                            .Where(Predicate.not(Predicate.within("x")));

                List <string> result = traversal.Values("name").Next();
                CheckOrderedResults(new List <string> {
                    "ripple"
                }, result);
            }
        }
示例#11
0
        public void HasVIdOutEHasWeightInside0dot0d0dot6dInV()
        {
            using (GraphViewCommand command = new GraphViewCommand(graphConnection))
            {
                string vertexId = this.ConvertToVertexId(command, "marko");

                GraphTraversal2 traversal = command.g().V(vertexId).OutE()
                                            .Has("weight", Predicate.inside(0.0d, 0.6d)).InV();

                List <string> result = traversal.Values("name").Next();
                Assert.AreEqual(2, result.Count);
                foreach (string res in result)
                {
                    Assert.IsTrue(string.Equals(res, "vadas") || string.Equals(res, "lop"));
                }
            }
        }