Java 类org.neo4j.graphdb.traversal.BranchState 实例源码

项目:power_grid    文件:EnergizationExpander.java   
@Override
public Iterable<Relationship> expand(Path path, BranchState<Double> branchState) {
    ArrayList<Relationship> rels = new ArrayList<>();
    Node endNode = path.endNode();
    Double voltage = (Double) endNode.getProperty("voltage", 999.0);
    if (voltage <= branchState.getState()) {
        // Set the new voltage
        branchState.setState(voltage);

        endNode.getRelationships(Direction.OUTGOING, RelationshipTypes.CONNECTED).forEach(rel -> {
            if ((Boolean)rel.getProperty("incoming_switch_on", false) &&
                (Boolean)rel.getProperty("outgoing_switch_on", false)) {
                rels.add(rel);
            }
        });
    }

    return rels;
}
项目:neo_airlines    文件:NonStopExpander.java   
@Override
public Iterable<Relationship> expand(Path path, BranchState state) {
    if (System.currentTimeMillis() < stopTime) {
        switch (path.length()) {
            case 0:
                return path.endNode().getRelationships(Direction.OUTGOING, RelationshipTypes.HAS_DESTINATION);
            case 1: {
                Node lastNode = path.endNode();
                if (destinations.contains((String) lastNode.getProperty("code"))) {
                    return path.endNode().getRelationships(Direction.OUTGOING, relationshipTypes);
                } else {
                    return Collections.emptyList();
                }
            }
             case 2:
             case 3: {
                 return path.endNode().getRelationships(Direction.OUTGOING, relationshipTypes);
             }
            default:
                return Collections.emptyList();
        }
    } else {
        return Collections.emptyList();
    }
}
项目:obelix    文件:TimeStampExpander.java   
@Override
public final Iterable<Relationship> expand(final Path path, final BranchState state) {

    List<Relationship> result = new ArrayList<>();

    if (this.since == Long.MIN_VALUE && this.until == Long.MAX_VALUE) {
        return path.endNode().getRelationships();
    }

    if (path.length() >= this.depth) {
        return result;
    }

    for (Relationship rel : path.endNode().getRelationships()) {
        long current = Long.parseLong(rel.getProperty("timestamp").toString());
        if (until > current && current > since) {
            result.add(rel);
        }
    }

    return result;
}
项目:steps    文件:StepsBuilder.java   
private StepExpander buildStepExpander( RelationshipFilterDescriptor relationshipDescriptor )
{
    List<PropertyContainerPredicate> relationshipPredicateList = relationshipDescriptor.getFilterPredicates();

    final PredicateGroup<PropertyContainer> relationshipPredicates = ( relationshipPredicateList.isEmpty() ) ? null
            : new PredicateGroup<PropertyContainer>(
                    relationshipPredicateList.toArray( new PropertyContainerPredicate[relationshipPredicateList.size()] ) );

    final Function<Node, Iterator<Relationship>> expandFun = relationshipDescriptor.expandFun();

    return new StepExpander()
    {
        @Override
        public Iterable<Relationship> expand( Path path, BranchState<StepState> state )
        {
            final Node startNode = path.endNode();
            Iterator<Relationship> relationships = ( null == relationshipPredicates ) ? expandFun.apply( startNode )
                    : Iterators.filter( expandFun.apply( startNode ), relationshipPredicates );
            return ImmutableList.copyOf( relationships );
        }
    };
}
项目:checklistbank    文件:TaxonomicOrderExpander.java   
@Override
public Iterable<Relationship> expand(Path path, BranchState state) {
  List<Relationship> children = CHILDREN_ORDER.sortedCopy(path.endNode().getRelationships(RelType.PARENT_OF, Direction.OUTGOING));
  if (synRels.isEmpty()) {
    return children;
  } else {
    List<Iterable<Relationship>> synResults = Lists.newArrayList();
    for (RelType rt : synRels) {
      synResults.add(path.endNode().getRelationships(rt, Direction.INCOMING));
    }
    return Iterables.concat(
        SYNONYM_ORDER.sortedCopy(Iterables.concat(synResults)),
        children
    );
  }
}
项目:cypher_hip_hop    文件:HipHopExpander.java   
@Override
public Iterable<Relationship> expand(Path path, BranchState branchState) {
    if (path.endNode().hasLabel(stopLabel)) {
        return Collections.emptyList();
    }
    if (path.length() % 2 == 0) {
        return path.endNode().getRelationships(Direction.INCOMING);
    } else {
        return path.endNode().getRelationships(Direction.OUTGOING);
    }
}
项目:cypher_hip_hop    文件:HipHopEvaluator.java   
@Override
public Evaluation evaluate(Path path, BranchState branchState) {
    if (path.endNode().hasLabel(stopLabel)) {
        return Evaluation.EXCLUDE_AND_PRUNE;
    } else {
        return Evaluation.INCLUDE_AND_CONTINUE;
    }
}
项目:power_grid    文件:EnergizationEvaluator.java   
@Override
public Evaluation evaluate(Path path, BranchState<Double> branchState) {
    // Path with just the single node, ignore it and continue
    if (path.length() == 0 ) {
        return Evaluation.INCLUDE_AND_CONTINUE;
    }
    // Make sure last Equipment voltage is equal to or lower than previous voltage
    Double voltage = (Double) path.endNode().getProperty("voltage", 999.0);
    if (voltage <= branchState.getState()) {
        return Evaluation.INCLUDE_AND_CONTINUE;
    } else {
        return Evaluation.EXCLUDE_AND_PRUNE;
    }
}
项目:steps    文件:StepsExpander.java   
@Override
public Iterable<Relationship> expand( Path path, BranchState<StepState> state )
{
    StepExpander stepExpander = stepExpanders[state.getState().step()];
    /*
     * Return List because Iterable should be capable of returning multiple Iterator instances
     * Wrapping Iterator in an Iterable that can only consume it once would break the Iterable contract
     */
    return ImmutableList.copyOf( stepExpander.expand( path, state ) );
}
项目:SciGraph    文件:DirectionalPathExpander.java   
@Override
public Iterable<Relationship> expand(Path path, BranchState<Void> state) {
  return path.endNode().getRelationships(direction);
}
项目:steps    文件:StepsEvaluator.java   
@Override
public Evaluation evaluate( Path path, BranchState<StepState> state )
{
    int currentStep = state.getState().step();
    int stepStateState = state.getState().state();
    while ( true )
    {
        StepEvaluationResult result = stepEvaluators[currentStep].evaluate( path, stepStateState );
        switch ( result.stepEvaluation() )
        {
        case REJECT_STAY_EXCLUDE_PRUNE:
            /*
             * evaluator failed fatally
             */
            return Evaluation.EXCLUDE_AND_PRUNE;
        case REJECT_ADVANCE_EXCLUDE_CONTINUE:
            /*
             * evaluator failed & exhausted
             * advance evaluator immediately (current step) & retry
             */
            currentStep++;
            stepStateState = result.stepState();
            continue;
        case ACCEPT_ADVANCE_EXCLUDE_CONTINUE:
            /*
             * evaluator succeeded & exhausted
             * advance evaluator for next step
             */
            currentStep++;
            state.setState( new StepState( currentStep, result.stepState() ) );
            return Evaluation.EXCLUDE_AND_CONTINUE;
        case ACCEPT_STAY_EXCLUDE_CONTINUE:
            /*
             * evaluator succeeded but not exhausted
             * reuse evaluator @ next step
             */
            state.setState( new StepState( currentStep, result.stepState() ) );
            return Evaluation.EXCLUDE_AND_CONTINUE;
        case ACCEPT_STAY_INCLUDE_CONTINUE:
            /*
             * final evaluator succeeded but not exhausted
             * return path & reuse evaluator @ next step
             */
            state.setState( new StepState( currentStep, result.stepState() ) );
            return Evaluation.INCLUDE_AND_CONTINUE;
        case ACCEPT_ADVANCE_INCLUDE_PRUNE:
            /*
             * final evaluator succeeded & exhausted
             * return path
             */
            return Evaluation.INCLUDE_AND_PRUNE;
        }
    }
}