Example #1
0
//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);
        }
Example #2
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
//ORIGINAL LINE: private org.neo4j.graphdb.traversal.Traverser traverser(org.neo4j.graphdb.Node start, final org.neo4j.graphdb.Node end, org.neo4j.graphalgo.impl.util.PathInterest interest)
        private Traverser Traverser(Node start, Node end, PathInterest interest)
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.apache.commons.lang3.mutable.MutableDouble shortestSoFar = new org.apache.commons.lang3.mutable.MutableDouble(Double.MAX_VALUE);
            MutableDouble shortestSoFar = new MutableDouble(double.MaxValue);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.apache.commons.lang3.mutable.MutableDouble startSideShortest = new org.apache.commons.lang3.mutable.MutableDouble(0);
            MutableDouble startSideShortest = new MutableDouble(0);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.apache.commons.lang3.mutable.MutableDouble endSideShortest = new org.apache.commons.lang3.mutable.MutableDouble(0);
            MutableDouble endSideShortest  = new MutableDouble(0);
            PathExpander  dijkstraExpander = new DijkstraBidirectionalPathExpander(_expander, shortestSoFar, true, startSideShortest, endSideShortest, _epsilon);

            GraphDatabaseService db = start.GraphDatabase;

            TraversalDescription side = Db.traversalDescription().expand(dijkstraExpander, _stateFactory).order(new DijkstraSelectorFactory(interest, _costEvaluator)).evaluator(new DijkstraBidirectionalEvaluator(_costEvaluator)).uniqueness(Uniqueness.NODE_PATH);

            TraversalDescription startSide = side;
            TraversalDescription endSide   = side.Reverse();

            BidirectionalTraversalDescription traversal = Db.bidirectionalTraversalDescription().startSide(startSide).endSide(endSide).collisionEvaluator(Evaluators.all()).collisionPolicy((evaluator, pathPredicate) => new DijkstraBranchCollisionDetector(evaluator, _costEvaluator, shortestSoFar, _epsilon, pathPredicate));

            _lastTraverser = traversal.Traverse(start, end);
            return(_lastTraverser);
        }