//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void makeSureAMaxResultCountIsObeyed() public virtual void MakeSureAMaxResultCountIsObeyed() { // Layout: // // (a)--(b)--(c)--(d)--(e) // | / | \ // (f)--(g)---------(h) | \ // | | | // (i)-----------------(j) | // | | // (k)---------------------- // Graph.makeEdgeChain("a,b,c,d,e"); Graph.makeEdgeChain("a,f,g,h,e"); Graph.makeEdgeChain("f,i,j,e"); Graph.makeEdgeChain("i,k,e"); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.graphdb.Node a = graph.getNode("a"); Node a = Graph.getNode("a"); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.graphdb.Node e = graph.getNode("e"); Node e = Graph.getNode("e"); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.graphdb.PathExpander expander = org.neo4j.graphdb.PathExpanders.forTypeAndDirection(R1, OUTGOING); PathExpander expander = PathExpanders.forTypeAndDirection(R1, OUTGOING); TestShortestPathFinder(finder => assertEquals(4, Iterables.count(finder.findAllPaths(a, e))), expander, 10, 10); for (int i = 4; i >= 1; i--) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final int count = i; int count = i; TestShortestPathFinder(finder => assertEquals(count, Iterables.count(finder.findAllPaths(a, e))), expander, 10, count); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testExactDepthFinder() public virtual void TestExactDepthFinder() { // Layout (a to k): // // (a)--(c)--(g)--(k) // / / // (b)-----(d)------(j) // | \ / // (e)--(f)--(h)--(i) // Graph.makeEdgeChain("a,c,g,k"); Graph.makeEdgeChain("a,b,d,j,k"); Graph.makeEdgeChain("b,e,f,h,i,j"); Graph.makeEdgeChain("d,h"); PathExpander <object> expander = PathExpanders.forTypeAndDirection(MyRelTypes.R1, Direction.OUTGOING); Node a = Graph.getNode("a"); Node k = Graph.getNode("k"); AssertPaths(GraphAlgoFactory.pathsWithLength(expander, 3).findAllPaths(a, k), "a,c,g,k"); AssertPaths(GraphAlgoFactory.pathsWithLength(expander, 4).findAllPaths(a, k), "a,b,d,j,k"); AssertPaths(GraphAlgoFactory.pathsWithLength(expander, 5).findAllPaths(a, k)); AssertPaths(GraphAlgoFactory.pathsWithLength(expander, 6).findAllPaths(a, k), "a,b,d,h,i,j,k"); AssertPaths(GraphAlgoFactory.pathsWithLength(expander, 7).findAllPaths(a, k), "a,b,e,f,h,i,j,k"); AssertPaths(GraphAlgoFactory.pathsWithLength(expander, 8).findAllPaths(a, k)); }
public virtual Stream <NodeResult> GraphAlgosDijkstra(Node start, Node end, string relType, string weightProperty) { PathFinder <WeightedPath> pathFinder = GraphAlgoFactory.dijkstra(PathExpanders.forTypeAndDirection(RelationshipType.withName(relType), Direction.BOTH), weightProperty); WeightedPath path = pathFinder.FindSinglePath(start, end); //JAVA TO C# CONVERTER TODO TASK: Method reference constructor syntax is not converted by Java to C# Converter: return(StreamSupport.stream(path.Nodes().spliterator(), false).map(NodeResult::new)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testSimplestGraph() public virtual void TestSimplestGraph() { // Layout: // __ // / \ // (s) (t) // \__/ Graph.makeEdge("s", "t"); Graph.makeEdge("s", "t"); TestShortestPathFinder(finder => { IEnumerable <Path> paths = finder.findAllPaths(Graph.getNode("s"), Graph.getNode("t")); AssertPaths(paths, "s,t", "s,t"); AssertPaths(asList(finder.findSinglePath(Graph.getNode("s"), Graph.getNode("t"))), "s,t"); }, PathExpanders.forTypeAndDirection(R1, BOTH), 1); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void makeSureShortestPathsReturnsNoLoops() public virtual void MakeSureShortestPathsReturnsNoLoops() { // Layout: // // (a)-->(b)==>(c)-->(e) // ^ / // \ v // (d) // Graph.makeEdgeChain("a,b,c,d,b,c,e"); TestShortestPathFinder(finder => { Node a = Graph.getNode("a"); Node e = Graph.getNode("e"); AssertPaths(finder.findAllPaths(a, e), "a,b,c,e", "a,b,c,e"); }, PathExpanders.forTypeAndDirection(R1, BOTH), 6); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void makeSureRelationshipNotConnectedIssueNotThere() public virtual void MakeSureRelationshipNotConnectedIssueNotThere() { /* * (g) * / ^ * v \ * (a)<--(b)<--(c)<--(d)<--(e)<--(f) (i) * ^ / * \ v * (h) */ Graph.makeEdgeChain("i,g,f,e,d,c,b,a"); Graph.makeEdgeChain("i,h,f"); TestShortestPathFinder(finder => { Node start = Graph.getNode("a"); Node end = Graph.getNode("i"); AssertPaths(finder.findAllPaths(start, end), "a,b,c,d,e,f,g,i", "a,b,c,d,e,f,h,i"); }, PathExpanders.forTypeAndDirection(R1, INCOMING), 10); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testSmallGraphWithDefaults() public virtual void TestSmallGraphWithDefaults() { Relationship shortCTOXRelationship = CreateGraph( true ); PathFinder<WeightedPath> finder = factory.dijkstra( PathExpanders.forTypeAndDirection( MyRelTypes.R1, Direction.OUTGOING ), CommonEvaluators.doubleCostEvaluator( "cost", 1.0d ) ); // Assert that there are two matching paths Node startNode = Graph.getNode( "start" ); Node endNode = Graph.getNode( "x" ); AssertPaths( finder.FindAllPaths( startNode, endNode ), "start,a,b,c,x", "start,a,b,c,d,e,x" ); // Assert that for the shorter one it picked the correct relationship // of the two from (c) --> (x) foreach ( WeightedPath path in finder.FindAllPaths( startNode, endNode ) ) { if ( GetPathDef( path ).Equals( "start,a,b,c,x" ) ) { AssertContainsRelationship( path, shortCTOXRelationship ); } } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testAnotherSimpleGraph() public virtual void TestAnotherSimpleGraph() { // Layout: // (m) // / \ // (s) (o)---(t) // \ / \ // (n)---(p)---(q) Graph.makeEdge("s", "m"); Graph.makeEdge("m", "o"); Graph.makeEdge("s", "n"); Graph.makeEdge("n", "p"); Graph.makeEdge("p", "q"); Graph.makeEdge("q", "t"); Graph.makeEdge("n", "o"); Graph.makeEdge("o", "t"); TestShortestPathFinder(finder => { IEnumerable <Path> paths = finder.findAllPaths(Graph.getNode("s"), Graph.getNode("t")); AssertPaths(paths, "s,m,o,t", "s,n,o,t"); }, PathExpanders.forTypeAndDirection(R1, BOTH), 6); }
// Attempt at recreating this issue without cypher // https://github.com/neo4j/neo4j/issues/4160 //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldAbortAsSoonAsPossible() public virtual void ShouldAbortAsSoonAsPossible() { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.graphdb.Label A = org.neo4j.graphdb.Label.label("A"); Label a = Label.label("A"); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.graphdb.Label B = org.neo4j.graphdb.Label.label("B"); Label b = Label.label("B"); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.graphdb.Label C = org.neo4j.graphdb.Label.label("C"); Label c = Label.label("C"); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.graphdb.Label D = org.neo4j.graphdb.Label.label("D"); Label d = Label.label("D"); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.graphdb.Label E = org.neo4j.graphdb.Label.label("E"); Label e = Label.label("E"); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.graphdb.Label F = org.neo4j.graphdb.Label.label("F"); Label f = Label.label("F"); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.graphdb.RelationshipType relType = org.neo4j.graphdb.RelationshipType.withName("TO"); RelationshipType relType = RelationshipType.withName("TO"); RecursiveSnowFlake(null, 0, 4, 5, new Label[] { a, b, c, d, e }, relType); Node a = GetNodeByLabel(a); using (ResourceIterator <Node> allE = GraphDb.findNodes(e)) { while (allE.MoveNext()) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.graphdb.Node e = allE.Current; Node e = allE.Current; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.graphdb.Node f = graphDb.createNode(F); Node f = GraphDb.createNode(f); f.CreateRelationshipTo(e, relType); } } //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final CountingPathExpander countingPathExpander = new CountingPathExpander(org.neo4j.graphdb.PathExpanders.forTypeAndDirection(relType, org.neo4j.graphdb.Direction.OUTGOING)); CountingPathExpander countingPathExpander = new CountingPathExpander(this, PathExpanders.forTypeAndDirection(relType, Direction.OUTGOING)); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final ShortestPath shortestPath = new ShortestPath(Integer.MAX_VALUE, countingPathExpander, Integer.MAX_VALUE); ShortestPath shortestPath = new ShortestPath(int.MaxValue, countingPathExpander, int.MaxValue); using (ResourceIterator <Node> allF = GraphDb.findNodes(f)) { while (allF.MoveNext()) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.graphdb.Node f = allF.Current; Node f = allF.Current; shortestPath.FindAllPaths(a, f); } } assertEquals("There are 625 different end nodes. The algorithm should start one traversal for each such node. " + "That is 625*2 visited nodes if traversal is interrupted correctly.", 1250, countingPathExpander.NodesVisited.intValue()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void unfortunateRelationshipOrderingInTriangle() public virtual void UnfortunateRelationshipOrderingInTriangle() { /* * (b) * ^ \ * / v * (a)---->(c) * * Relationships are created in such a way that they are iterated in the worst order, * i.e. (S) a-->b, (E) c<--b, (S) a-->c */ Graph.makeEdgeChain("a,b,c"); Graph.makeEdgeChain("a,c"); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.graphdb.Node a = graph.getNode("a"); Node a = Graph.getNode("a"); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.graphdb.Node c = graph.getNode("c"); Node c = Graph.getNode("c"); TestShortestPathFinder(finder => assertPathDef(finder.findSinglePath(a, c), "a", "c"), PathExpanders.forTypeAndDirection(R1, OUTGOING), 2); TestShortestPathFinder(finder => assertPathDef(finder.findSinglePath(c, a), "c", "a"), PathExpanders.forTypeAndDirection(R1, INCOMING), 2); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void makeSureShortestPathCanBeFetchedEvenIfANodeHasLoops() public virtual void MakeSureShortestPathCanBeFetchedEvenIfANodeHasLoops() { // Layout: // // = means loop :) // // (m) // / \ // (s) (o)= // \ / // (n)= // | // (p) Graph.makeEdgeChain("m,s,n,p"); Graph.makeEdgeChain("m,o,n"); Graph.makeEdge("o", "o"); Graph.makeEdge("n", "n"); TestShortestPathFinder(finder => assertPaths(finder.findAllPaths(Graph.getNode("m"), Graph.getNode("p")), "m,s,n,p", "m,o,n,p"), PathExpanders.forTypeAndDirection(R1, BOTH), 3); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testDirectedFinder() public virtual void TestDirectedFinder() { // Layout: // // (a)->(b)->(c)->(d)->(e)->(f)-------\ // \ v // >(g)->(h)->(i)->(j)->(k)->(l)->(m) // Graph.makeEdgeChain("a,b,c,d,e,f,m"); Graph.makeEdgeChain("a,g,h,i,j,k,l,m"); TestShortestPathFinder(finder => assertPaths(finder.findAllPaths(Graph.getNode("a"), Graph.getNode("j")), "a,g,h,i,j"), PathExpanders.forTypeAndDirection(R1, OUTGOING), 4); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testCrossedCircle() public virtual void TestCrossedCircle() { // Layout: // (s) // / \ // (3) (1) // | \ / | // | / \ | // (4) (2) // \ / // (t) Graph.makeEdge("s", "1"); Graph.makeEdge("s", "3"); Graph.makeEdge("1", "2"); Graph.makeEdge("1", "4"); Graph.makeEdge("3", "2"); Graph.makeEdge("3", "4"); Graph.makeEdge("2", "t"); Graph.makeEdge("4", "t"); TestShortestPathFinder(finder => assertPaths(finder.findAllPaths(Graph.getNode("s"), Graph.getNode("t")), "s,1,2,t", "s,1,4,t", "s,3,2,t", "s,3,4,t"), PathExpanders.forTypeAndDirection(R1, BOTH), 3); }