//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void evenDifferentDirectionsKeepsOrder() public virtual void EvenDifferentDirectionsKeepsOrder() { PathExpander expander = (new OrderedByTypeExpander()).add(_next, INCOMING).add(_firstComment).add(_comment).add(_next, OUTGOING); IEnumerator <Node> itr = GraphDb.traversalDescription().depthFirst().expand(expander).traverse(Node("A2")).nodes().GetEnumerator(); AssertOrder(itr, "A2", "A1", "C1", "C2", "C3", "C4", "C5", "C6", "A3", "C7", "C8", "C9"); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void myFriendsAsWellAsYourFriends() public virtual void MyFriendsAsWellAsYourFriends() { /* * Hey, this looks like a futuristic gun or something * * (f8) _----(f1)--(f5) * | / / * (f7)--(you)--(me)--(f2)--(f6) * | / \ * (f4) (f3) */ CreateGraph("you KNOW me", "you KNOW f1", "you KNOW f4", "me KNOW f1", "me KNOW f4", "me KNOW f2", "me KNOW f3", "f1 KNOW f5", "f2 KNOW f6", "you KNOW f7", "f7 KNOW f8"); using (Transaction tx = BeginTx()) { RelationshipType knowRelType = withName("KNOW"); Node you = GetNodeWithName("you"); Node me = GetNodeWithName("me"); string[] levelOneFriends = new string[] { "f1", "f2", "f3", "f4", "f7" }; TraversalDescription levelOneTraversal = GraphDb.traversalDescription().relationships(knowRelType).evaluator(atDepth(1)); ExpectNodes(levelOneTraversal.DepthFirst().traverse(you, me), levelOneFriends); ExpectNodes(levelOneTraversal.BreadthFirst().traverse(you, me), levelOneFriends); string[] levelTwoFriends = new string[] { "f5", "f6", "f8" }; TraversalDescription levelTwoTraversal = GraphDb.traversalDescription().relationships(knowRelType).evaluator(atDepth(2)); ExpectNodes(levelTwoTraversal.DepthFirst().traverse(you, me), levelTwoFriends); ExpectNodes(levelTwoTraversal.BreadthFirst().traverse(you, me), levelTwoFriends); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void nodeLevelUniqueness() public virtual void NodeLevelUniqueness() { /* * (b) * / | \ * (e)==(a)--(c) * \ | * (d) */ CreateGraph("a TO b", "a TO c", "a TO d", "a TO e", "a TO e", "b TO e", "d TO e", "c TO b"); RelationshipType to = withName("TO"); using (Transaction tx = BeginTx()) { Node a = GetNodeWithName("a"); Node e = GetNodeWithName("e"); Path[] paths = SplitPathsOnePerLevel(GraphDb.traversalDescription().relationships(to, OUTGOING).uniqueness(NODE_LEVEL).evaluator(includeWhereEndNodeIs(e)).traverse(a)); NodePathRepresentation pathRepresentation = new NodePathRepresentation(NamePropertyRepresentation); assertEquals("a,e", pathRepresentation.Represent(paths[1])); string levelTwoPathRepresentation = pathRepresentation.Represent(paths[2]); assertTrue(levelTwoPathRepresentation.Equals("a,b,e") || levelTwoPathRepresentation.Equals("a,d,e")); assertEquals("a,c,b,e", pathRepresentation.Represent(paths[3])); tx.Success(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testCircularBug() public virtual void TestCircularBug() { const long timestamp = 3; using (Transaction tx = BeginTx()) { GetNodeWithName("2").setProperty("timestamp", 1L); GetNodeWithName("3").setProperty("timestamp", 2L); tx.Success(); } using (Transaction tx2 = BeginTx()) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.graphdb.RelationshipType type = org.neo4j.graphdb.RelationshipType.withName("TO"); RelationshipType type = RelationshipType.withName("TO"); IEnumerator <Node> nodes = GraphDb.traversalDescription().depthFirst().relationships(type, Direction.OUTGOING).evaluator(path => { Relationship rel = path.lastRelationship(); bool relIsOfType = rel != null && rel.isType(type); bool prune = relIsOfType && ( long? )path.endNode().getProperty("timestamp").Value >= timestamp; return(Evaluation.of(relIsOfType, !prune)); }).traverse(Node("1")).nodes().GetEnumerator(); //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: assertEquals("2", nodes.next().getProperty("name")); //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: assertEquals("3", nodes.next().getProperty("name")); //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: assertFalse(nodes.hasNext()); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testPostorderDepthFirstReturnsDeeperNodesFirst() public virtual void TestPostorderDepthFirstReturnsDeeperNodesFirst() { Traverser traverser = GraphDb.traversalDescription().order(POSTORDER_DEPTH_FIRST).traverse(Node("1")); int i = 0; IList <string> encounteredNodes = new List <string>(); using (Transaction tx = BeginTx()) { foreach (Path pos in traverser) { encounteredNodes.Add(( string )pos.EndNode().getProperty("name")); assertEquals(ExpectedDepth(12 - i++), pos.Length()); } tx.Success(); } assertEquals(13, i); assertTrue(encounteredNodes.IndexOf("5") < encounteredNodes.IndexOf("2")); assertTrue(encounteredNodes.IndexOf("6") < encounteredNodes.IndexOf("2")); assertTrue(encounteredNodes.IndexOf("7") < encounteredNodes.IndexOf("2")); assertTrue(encounteredNodes.IndexOf("8") < encounteredNodes.IndexOf("3")); assertTrue(encounteredNodes.IndexOf("9") < encounteredNodes.IndexOf("3")); assertTrue(encounteredNodes.IndexOf("A") < encounteredNodes.IndexOf("3")); assertTrue(encounteredNodes.IndexOf("B") < encounteredNodes.IndexOf("4")); assertTrue(encounteredNodes.IndexOf("C") < encounteredNodes.IndexOf("4")); assertTrue(encounteredNodes.IndexOf("D") < encounteredNodes.IndexOf("4")); assertTrue(encounteredNodes.IndexOf("2") < encounteredNodes.IndexOf("1")); assertTrue(encounteredNodes.IndexOf("3") < encounteredNodes.IndexOf("1")); assertTrue(encounteredNodes.IndexOf("4") < encounteredNodes.IndexOf("1")); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testBidirectionalPath() public virtual void TestBidirectionalPath() { TraversalDescription side = GraphDb.traversalDescription().uniqueness(Uniqueness.NODE_PATH); BidirectionalTraversalDescription bidirectional = GraphDb.bidirectionalTraversalDescription().mirroredSides(side); Path bidirectionalPath = GetFirstPath(bidirectional.Traverse(_a, _e)); AssertPathIsCorrect(bidirectionalPath); Path path = GetFirstPath(bidirectional.Traverse(_a, _e)); Node node = path.StartNode(); assertEquals(_a, node); // White box testing below: relationships(), nodes(), reverseRelationships(), reverseNodes() // does cache the start node if not already cached, so just make sure they to it properly. bidirectionalPath = GetFirstPath(bidirectional.Traverse(_a, _e)); bidirectionalPath.Relationships(); assertEquals(_a, bidirectionalPath.StartNode()); bidirectionalPath = GetFirstPath(bidirectional.Traverse(_a, _e)); bidirectionalPath.Nodes(); assertEquals(_a, bidirectionalPath.StartNode()); bidirectionalPath = GetFirstPath(bidirectional.Traverse(_a, _e)); bidirectionalPath.ReverseRelationships(); assertEquals(_a, bidirectionalPath.StartNode()); bidirectionalPath = GetFirstPath(bidirectional.Traverse(_a, _e)); bidirectionalPath.ReverseNodes(); assertEquals(_a, bidirectionalPath.StartNode()); bidirectionalPath = GetFirstPath(bidirectional.Traverse(_a, _e)); bidirectionalPath.GetEnumerator(); assertEquals(_a, bidirectionalPath.StartNode()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void sortFriendsByName() public virtual void SortFriendsByName() { /* * (Abraham) * | * (me)--(George)--(Dan) * | | * (Zack)---(Andreas) * | * (Nicholas) */ string me = "me"; string abraham = "Abraham"; string george = "George"; string dan = "Dan"; string zack = "Zack"; string andreas = "Andreas"; string nicholas = "Nicholas"; string knows = "KNOWS"; CreateGraph(Triplet(me, knows, abraham), Triplet(me, knows, george), Triplet(george, knows, dan), Triplet(me, knows, zack), Triplet(zack, knows, andreas), Triplet(george, knows, andreas), Triplet(andreas, knows, nicholas)); using (Transaction tx = BeginTx()) { IList <Node> nodes = AsNodes(abraham, george, dan, zack, andreas, nicholas); assertEquals(nodes, Iterables.asCollection(GraphDb.traversalDescription().evaluator(excludeStartPosition()).sort(endNodeProperty("name")).traverse(GetNodeWithName(me)).nodes())); tx.Success(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void useTraverserInsideTraverser() public virtual void UseTraverserInsideTraverser() { /* * (a)-->(b)-->(c) * | * \/ * (d)-->(e)-->(f) * */ CreateGraph("a FIRST d", "a TO b", "b TO c", "d TO e", "e TO f"); using (Transaction tx = BeginTx()) { TraversalDescription firstTraverser = GraphDb.traversalDescription().relationships(RelationshipType.withName("FIRST")).evaluator(Evaluators.toDepth(1)); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final Iterable<org.neo4j.graphdb.Path> firstResult = firstTraverser.traverse(getNodeWithName("a")); IEnumerable <Path> firstResult = firstTraverser.Traverse(GetNodeWithName("a")); IEnumerable <Node> startNodesForNestedTraversal = new IterableWrapperAnonymousInnerClass(this, firstResult); TraversalDescription nestedTraversal = GraphDb.traversalDescription().evaluator(Evaluators.atDepth(2)); ExpectPaths(nestedTraversal.Traverse(startNodesForNestedTraversal), "a,b,c", "d,e,f"); tx.Success(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void depths() public virtual void Depths() { Node a = GetNodeWithName("a"); ExpectPaths(GraphDb.traversalDescription().evaluator(Evaluators.atDepth(1)).traverse(a), "a,b", "a,f"); ExpectPaths(GraphDb.traversalDescription().evaluator(Evaluators.fromDepth(2)).traverse(a), "a,f,g", "a,b,h", "a,b,h,i", "a,b,h,i,k", "a,b,c", "a,b,c,d", "a,b,c,d,e", "a,b,c,d,e,j"); ExpectPaths(GraphDb.traversalDescription().evaluator(Evaluators.toDepth(2)).traverse(a), "a", "a,b", "a,b,c", "a,b,h", "a,f", "a,f,g"); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testTraverseRelationshipsWithStartNodeNotIncluded() public virtual void TestTraverseRelationshipsWithStartNodeNotIncluded() { using (Transaction transaction = BeginTx()) { TraversalDescription traversal = GraphDb.traversalDescription().evaluator(excludeStartPosition()); assertEquals(1, Iterables.count(traversal.Traverse(Node("1")).relationships())); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void lastRelationshipTypeEvaluator() public virtual void LastRelationshipTypeEvaluator() { Node a = GetNodeWithName("a"); ExpectPaths(GraphDb.traversalDescription().evaluator(lastRelationshipTypeIs(INCLUDE_AND_PRUNE, EXCLUDE_AND_CONTINUE, Types.C)).traverse(a), "a,b,c,d,e", "a,f,g", "a,b,h"); ExpectPaths(GraphDb.traversalDescription().evaluator(lastRelationshipTypeIs(INCLUDE_AND_CONTINUE, EXCLUDE_AND_CONTINUE, Types.C)).traverse(a), "a,b,c,d,e", "a,f,g", "a,b,h", "a,b,h,i,k"); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void endNodeIs() public virtual void EndNodeIs() { Node a = GetNodeWithName("a"); Node c = GetNodeWithName("c"); Node h = GetNodeWithName("h"); Node g = GetNodeWithName("g"); ExpectPaths(GraphDb.traversalDescription().evaluator(includeWhereEndNodeIs(c, h, g)).traverse(a), "a,b,c", "a,b,h", "a,f,g"); ExpectPaths(GraphDb.traversalDescription().evaluator(includeWhereEndNodeIs(g)).traverse(a), "a,f,g"); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void makeSureNodesAreTraversedInCorrectOrder() public virtual void MakeSureNodesAreTraversedInCorrectOrder() { PathExpander expander = (new OrderedByTypeExpander()).add(_firstComment).add(_comment).add(_next); IEnumerator <Node> itr = GraphDb.traversalDescription().depthFirst().expand(expander).traverse(Node("A1")).nodes().GetEnumerator(); AssertOrder(itr, "A1", "C1", "C2", "C3", "A2", "C4", "C5", "C6", "A3", "C7", "C8", "C9"); expander = (new OrderedByTypeExpander()).add(_next).add(_firstComment).add(_comment); itr = GraphDb.traversalDescription().depthFirst().expand(expander).traverse(Node("A1")).nodes().GetEnumerator(); AssertOrder(itr, "A1", "A2", "A3", "C7", "C8", "C9", "C4", "C5", "C6", "C1", "C2", "C3"); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testPathIterator() public virtual void TestPathIterator() { Traverser traverse = GraphDb.traversalDescription().evaluator(atDepth(4)).traverse(Node("A")); using (ResourceIterator <Path> resourceIterator = traverse.GetEnumerator()) { //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: Path path = resourceIterator.next(); AssertPathIsCorrect(path); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void reverseNodes() public virtual void ReverseNodes() { Traverser traverse = GraphDb.traversalDescription().evaluator(atDepth(0)).traverse(_a); Path path = GetFirstPath(traverse); AssertContains(path.ReverseNodes(), _a); Traverser traverse2 = GraphDb.traversalDescription().evaluator(atDepth(4)).traverse(_a); Path path2 = GetFirstPath(traverse2); AssertContainsInOrder(path2.ReverseNodes(), _e, _d, _c, _b, _a); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testDepthFirstTraversalReturnsNodesOnCorrectDepths() public virtual void TestDepthFirstTraversalReturnsNodesOnCorrectDepths() { using (Transaction transaction = BeginTx()) { Traverser traverser = GraphDb.traversalDescription().depthFirst().traverse(Node("1")); int i = 0; foreach (Path pos in traverser) { assertEquals(ExpectedDepth(i++), pos.Length()); } assertEquals(13, i); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void pathWithConstantDirection() public virtual void PathWithConstantDirection() { Node l = GetNodeWithName("l"); ExpectPaths(GraphDb.traversalDescription().expand(PathExpanders.forConstantDirectionWithTypes(Types.A)).traverse(l), "l", "l,m", "l,m,n"); Node n = GetNodeWithName("n"); ExpectPaths(GraphDb.traversalDescription().expand(PathExpanders.forConstantDirectionWithTypes(Types.A)).traverse(n), "n", "n,m", "n,m,l", "n,o"); Node q = GetNodeWithName("q"); ExpectPaths(GraphDb.traversalDescription().expand(PathExpanders.forConstantDirectionWithTypes(Types.B)).traverse(q), "q", "q,p", "q,p,o"); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void relationshipsIteratorReturnAllNodes() public virtual void RelationshipsIteratorReturnAllNodes() { using (Transaction transaction = BeginTx()) { Traverser traverser = GraphDb.traversalDescription().traverse(Node("1")); int count = 0; foreach (Relationship relationship in traverser.Relationships()) { assertNotNull("returned relationships should not be. relationship #" + count, relationship); count++; } assertEquals(12, count); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testPostorderBreadthFirstReturnsDeeperNodesFirst() public virtual void TestPostorderBreadthFirstReturnsDeeperNodesFirst() { Traverser traverser = GraphDb.traversalDescription().order(POSTORDER_BREADTH_FIRST).traverse(Node("1")); Stack <ISet <string> > levels = new Stack <ISet <string> >(); levels.Push(new HashSet <>(asList("1"))); levels.Push(new HashSet <>(asList("2", "3", "4"))); levels.Push(new HashSet <>(asList("5", "6", "7", "8", "9", "A", "B", "C", "D"))); using (Transaction tx = BeginTx()) { AssertLevels(traverser, levels); tx.Success(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void nodesIteratorReturnAllNodes() public virtual void NodesIteratorReturnAllNodes() { using (Transaction transaction = BeginTx()) { Traverser traverser = GraphDb.traversalDescription().traverse(Node("1")); int count = 0; foreach (Node node in traverser.Nodes()) { assertNotNull("returned nodes should not be null. node #" + count, node); count++; } assertEquals(13, count); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void multipleCollisionEvaluators() public virtual void MultipleCollisionEvaluators() { /* * (g) * ^ \ * / v * (a)-->(b) (c) * | --^ ^ * v / | * (d)-->(e)----(f) */ CreateGraph("a TO b", "b TO g", "g TO c", "a TO d", "d TO e", "e TO c", "e TO f", "f TO c"); ExpectPaths(GraphDb.bidirectionalTraversalDescription().mirroredSides(GraphDb.traversalDescription().uniqueness(NODE_PATH)).collisionEvaluator(Evaluators.atDepth(3)).collisionEvaluator(includeIfContainsAll(GetNodeWithName("e"))).traverse(GetNodeWithName("a"), GetNodeWithName("c")), "a,d,e,c"); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void pathsForOneDirection() public virtual void PathsForOneDirection() { /* * (a)-->(b)==>(c)-->(d) * ^ / * \--(f)<--(e)<-/ */ CreateGraph("a TO b", "b TO c", "c TO d", "d TO e", "e TO f", "f TO a"); PathExpander <Void> expander = PathExpanders.forTypeAndDirection(To, OUTGOING); ExpectPaths(GraphDb.bidirectionalTraversalDescription().mirroredSides(GraphDb.traversalDescription().uniqueness(NODE_PATH).expand(expander)).traverse(GetNodeWithName("a"), GetNodeWithName("f")), "a,b,c,d,e,f"); ExpectPaths(GraphDb.bidirectionalTraversalDescription().mirroredSides(GraphDb.traversalDescription().uniqueness(RELATIONSHIP_PATH).expand(expander)).traverse(GetNodeWithName("a"), GetNodeWithName("f")), "a,b,c,d,e,f", "a,b,c,d,e,f"); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testBreadthFirst() public virtual void TestBreadthFirst() { Traverser traverser = GraphDb.traversalDescription().breadthFirst().traverse(Node("1")); Stack <ISet <string> > levels = new Stack <ISet <string> >(); levels.Push(new HashSet <>(asList("5", "6", "7", "8", "9", "A", "B", "C", "D"))); levels.Push(new HashSet <>(asList("2", "3", "4"))); levels.Push(new HashSet <>(asList("1"))); using (Transaction tx = BeginTx()) { AssertLevels(traverser, levels); tx.Success(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void relationshipLevelAndGlobalUniqueness() public virtual void RelationshipLevelAndGlobalUniqueness() { /* * (a)=TO=>(b)=TO=>(c)-TO->(d) * \====TO====>/ */ CreateGraph("a TO b", "b TO c", "a TO b", "b TO c", "a TO c", "a TO c", "c TO d"); RelationshipType to = withName("TO"); using (Transaction tx = BeginTx()) { Node a = GetNodeWithName("a"); Node d = GetNodeWithName("d"); IEnumerator <Path> paths = GraphDb.traversalDescription().relationships(to, OUTGOING).uniqueness(Uniqueness.NONE).evaluator(includeWhereEndNodeIs(d)).traverse(a).GetEnumerator(); int count = 0; while (paths.MoveNext()) { count++; paths.Current; } assertEquals("wrong number of paths calculated, the test assumption is wrong", 6, count); // Now do the same traversal but with unique per level relationships paths = GraphDb.traversalDescription().relationships(to, OUTGOING).uniqueness(RELATIONSHIP_LEVEL).evaluator(includeWhereEndNodeIs(d)).traverse(a).GetEnumerator(); count = 0; while (paths.MoveNext()) { count++; paths.Current; } assertEquals("wrong number of paths calculated with relationship level uniqueness", 2, count); /* * And yet again, but this time with global uniqueness, it should present only one path, since * c TO d is contained on all paths. */ paths = GraphDb.traversalDescription().relationships(to, OUTGOING).uniqueness(RELATIONSHIP_GLOBAL).evaluator(includeWhereEndNodeIs(d)).traverse(a).GetEnumerator(); count = 0; while (paths.MoveNext()) { count++; paths.Current; } assertEquals("wrong number of paths calculated with relationship global uniqueness", 1, count); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void multipleStartAndEndNodes() public virtual void MultipleStartAndEndNodes() { /* * (a)--\ -->(f) * v / * (b)-->(d)<--(e)-->(g) * ^ * (c)--/ */ CreateGraph("a TO d", "b TO d", "c TO d", "e TO d", "e TO f", "e TO g"); PathExpander <Void> expander = PathExpanderBuilder.empty().add(To).build(); TraversalDescription side = GraphDb.traversalDescription().uniqueness(NODE_PATH).expand(expander); ExpectPaths(GraphDb.bidirectionalTraversalDescription().mirroredSides(side).traverse(asList(GetNodeWithName("a"), GetNodeWithName("b"), GetNodeWithName("c")), asList(GetNodeWithName("f"), GetNodeWithName("g"))), "a,d,e,f", "a,d,e,g", "b,d,e,f", "b,d,e,g", "c,d,e,f", "c,d,e,g"); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void depthAsState() public virtual void DepthAsState() { /* * (a) -> (b) -> (c) -> (d) * \ ^ * v / * (e) -> (f) -> (g) -> (h) */ CreateGraph("a to b", "b to c", "c to d", "b to e", "e to f", "f to d", "f to g", "g to h"); using (Transaction tx = BeginTx()) { DepthStateExpander expander = new DepthStateExpander(); Iterables.count(GraphDb.traversalDescription().expand(expander, new Org.Neo4j.Graphdb.traversal.InitialBranchState_State <>(0, 0)).traverse(GetNodeWithName("a"))); tx.Success(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void everyOtherDepthAsState() public virtual void EveryOtherDepthAsState() { /* * (a) -> (b) -> (c) -> (e) */ CreateGraph("a to b", "b to c", "c to d", "d to e"); using (Transaction tx = BeginTx()) { /* * Asserts that state continues down branches even when expander doesn't * set new state for every step. */ IncrementEveryOtherDepthCountingExpander expander = new IncrementEveryOtherDepthCountingExpander(); Iterables.count(GraphDb.traversalDescription().expand(expander, new Org.Neo4j.Graphdb.traversal.InitialBranchState_State <>(0, 0)).traverse(GetNodeWithName("a"))); tx.Success(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testMaxDepthAndCustomPruneEvaluatorCombined() public virtual void TestMaxDepthAndCustomPruneEvaluatorCombined() { Evaluator lessThanThreeRels = path => count(path.endNode().getRelationships(Direction.OUTGOING).GetEnumerator()) < 3 ? Evaluation.INCLUDE_AND_PRUNE : Evaluation.INCLUDE_AND_CONTINUE; TraversalDescription description = GraphDb.traversalDescription().evaluator(Evaluators.all()).evaluator(toDepth(1)).evaluator(lessThanThreeRels); ISet <string> expectedNodes = new HashSet <string>(asList("a", "b", "c", "d", "e")); using (Transaction tx = BeginTx()) { foreach (Path position in description.Traverse(Node("a"))) { string name = ( string )position.EndNode().getProperty("name"); assertTrue(name + " shouldn't have been returned", expectedNodes.remove(name)); } tx.Success(); } assertTrue(expectedNodes.Count == 0); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void evaluateState() public virtual void EvaluateState() { /* * (a)-1->(b)-2->(c)-3->(d) * \ ^ * 4 6 * (e)-5->(f) */ CreateGraph("a TO b", "b TO c", "c TO d", "a TO e", "e TO f", "f TO c"); using (Transaction tx = BeginTx()) { PathEvaluator <int> evaluator = new PathEvaluator_AdapterAnonymousInnerClass(this); ExpectPaths(GraphDb.traversalDescription().uniqueness(Uniqueness.NODE_PATH).expand(new RelationshipWeightExpander(), new Org.Neo4j.Graphdb.traversal.InitialBranchState_State <>(1, 1)).evaluator(evaluator).traverse(GetNodeWithName("a")), "a,b,c"); tx.Success(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void reverseRelationships() public virtual void ReverseRelationships() { Traverser traverser = GraphDb.traversalDescription().evaluator(atDepth(0)).traverse(_a); Path path = GetFirstPath(traverser); assertFalse(path.ReverseRelationships().GetEnumerator().hasNext()); Traverser traverser2 = GraphDb.traversalDescription().evaluator(atDepth(4)).traverse(_a); Path path2 = GetFirstPath(traverser2); Node[] expectedNodes = new Node[] { _e, _d, _c, _b, _a }; int index = 0; foreach (Relationship rel in path2.ReverseRelationships()) { assertEquals("For index " + index, expectedNodes[index++], rel.EndNode); } assertEquals(4, index); }