Esempio n. 1
0
        protected internal override bool IncludePath(Path path, TraversalBranch startBranch, TraversalBranch endBranch)
        {
            if (!base.IncludePath(path, startBranch, endBranch))
            {
                return(false);
            }

            if (_depth == -1)
            {
                _depth = path.Length();
                return(true);
            }
            return(path.Length() == _depth);
        }
Esempio n. 2
0
        private TraversalBranch NextBranchFromSelector(TraversalContext metadata, BranchSelector selector, bool switchIfExhausted)
        {
            TraversalBranch result = selector.Next(metadata);

            if (result == null)
            {
                _selectors[_selectorIndex] = _emptySelector;
                if (switchIfExhausted)
                {
                    result = NextSelector().next(metadata);
                    if (result == null)
                    {
                        _selectors[_selectorIndex] = _emptySelector;
                    }
                }
            }
            return(result);
        }
        protected internal override bool IncludePath(Path path, TraversalBranch startBranch, TraversalBranch endBranch)
        {
            if (!base.IncludePath(path, startBranch, endBranch))
            {
                return(false);
            }

            /*
             * In most cases we could prune startBranch and endBranch here.
             *
             * Problem when assuming startBranch and endBranch are pruned:
             *
             * Path (s) -...- (c) weight x
             * path (s) -...- (a) weight x
             * path (d) -...- (t) weight y
             * path (b) -...- (t) weight y
             * rel (c) - (b) weight z
             * rel (a) - (b) weight z
             * rel (a) - (d) weight z
             *
             *    - (c) ----   ---- (d) -
             * ...           X           ...
             * /  (prune)> /   \ <(prune)  \
             * (s) -^v^v- (a) -- (b) -^v^v- (t)
             *
             * -^v^v- and ... meaning "some path"
             *
             * We expect following collisions:
             *      1. start (c) - (b) end. Result in path of weight x+z+y
             *      2. start (a) - (d) end. Result in path of weight x+z+y
             *      3. start (a) - (b) end. Result in path of weight x+z+y
             * However, if branches are pruned on collision 1 and 2. Collision 3 will never happen and thus
             * a path is missed.
             */

            double cost = (new WeightedPathImpl(_costEvaluator, path)).weight();

            if (cost < _shortestSoFar.doubleValue())
            {
                _shortestSoFar.Value = cost;
            }
            return(NoneStrictMath.compare(cost, _shortestSoFar.doubleValue(), _epsilon) <= 0);
        }
Esempio n. 4
0
 protected internal override double?AddPriority(TraversalBranch source, double?currentAggregatedValue, double?value)
 {
     return(WithDefault(currentAggregatedValue, 0d) + WithDefault(value, 0d));
 }
Esempio n. 5
0
 protected internal override double?CalculateValue(TraversalBranch next)
 {
     return(next.Length() == 0 ? 0d : _evaluator.getCost(next.LastRelationship(), OUTGOING));
 }
Esempio n. 6
0
 public abstract bool IsUniqueFirst(Org.Neo4j.Graphdb.traversal.TraversalBranch branch);
Esempio n. 7
0
 public abstract Evaluation Evaluate(Org.Neo4j.Graphdb.traversal.TraversalBranch branch, Org.Neo4j.Graphdb.traversal.BranchState <STATE> state);