本文整理汇总了Java中org.neo4j.graphdb.Path.endNode方法的典型用法代码示例。如果您正苦于以下问题:Java Path.endNode方法的具体用法?Java Path.endNode怎么用?Java Path.endNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.neo4j.graphdb.Path
的用法示例。
在下文中一共展示了Path.endNode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: evaluate
import org.neo4j.graphdb.Path; //导入方法依赖的package包/类
/**
* Evaluates a node and determines whether to include and / or continue.
* Continues on and returns exactly those nodes that:
* <ul>
* <li>haven't been visited yet and</li>
* <li>are the start node
* <ul>
* <li>have a sequence < threshold (and thus belong to the same cluster)</li>
* </ul>
* </ul>
*/
@Override
public Evaluation evaluate(Path path) {
Node end = path.endNode();
int score = is.compute(new Neo4jScoreContainer(end));
end.setProperty(SequenceProperties.INTERESTINGNESS.name(), score);
String id = (String) end.getProperty(ID.name());
if (!visited.contains(id)
&& (path.startNode().getId() == path.endNode().getId()
|| score < threshold)) {
visited.add(id);
return Evaluation.INCLUDE_AND_CONTINUE;
}
return Evaluation.EXCLUDE_AND_PRUNE;
}
示例2: call
import org.neo4j.graphdb.Path; //导入方法依赖的package包/类
@Override
public Map<String, Set<Long>> call() throws Exception {
logger.info("Processsing " + category);
Map<String, Set<Long>> map = new HashMap<String, Set<Long>>();
Set<Long> nodeSet = new HashSet<Long>();
Transaction tx = graphDb.beginTx();
try {
for (Path position : graphDb.traversalDescription().uniqueness(Uniqueness.NODE_GLOBAL).depthFirst()
.relationships(OwlRelationships.RDFS_SUBCLASS_OF, Direction.INCOMING).relationships(OwlRelationships.RDF_TYPE, Direction.INCOMING)
.relationships(OwlRelationships.OWL_EQUIVALENT_CLASS, Direction.BOTH).relationships(OwlRelationships.OWL_SAME_AS, Direction.BOTH)
.traverse(root)) {
Node end = position.endNode();
nodeSet.add(end.getId());
}
logger.info("Discovered " + nodeSet.size() + " nodes for " + category);
map.put(category, nodeSet);
} catch (Exception e) {
logger.warning("IRI not found for category: " + category);
} finally {
tx.success();
tx.close();
}
return map;
}
示例3: evaluate
import org.neo4j.graphdb.Path; //导入方法依赖的package包/类
@Override
public StepEvaluationResult evaluate( Path path, int stepState )
{
Node startNode = path.endNode();
int currentStepState = stepState + 1;
RepetitionState repetitionState = getRepetitionState( stepState );
switch ( repetitionState )
{
case TOO_LOW:
if ( isMatch( startNode ) )
return StepEvaluationResult.acceptStayExcludeContinue( currentStepState );
else
return StepEvaluationResult.REJECT_STAY_EXCLUDE_PRUNE;
case ONLY_IN_RANGE:
if ( isMatch( startNode ) )
return StepEvaluationResult.ACCEPT_ADVANCE_EXCLUDE_CONTINUE;
else
return StepEvaluationResult.REJECT_STAY_EXCLUDE_PRUNE;
case TOO_HIGH:
return StepEvaluationResult.REJECT_STAY_EXCLUDE_PRUNE;
default:
throw new RuntimeException( "Should never get here" );
}
}
示例4: buildStepExpander
import org.neo4j.graphdb.Path; //导入方法依赖的package包/类
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 );
}
};
}
示例5: evaluate
import org.neo4j.graphdb.Path; //导入方法依赖的package包/类
@Override
public Evaluation evaluate(Path path) {
Node lastNode = path.endNode();
if (!lastNode.hasLabel(Labels.AirportDay)){
return Evaluation.EXCLUDE_AND_CONTINUE;
} else if (destinations.contains( ((String)lastNode.getProperty("key")).substring(0,3) )) {
return Evaluation.INCLUDE_AND_PRUNE;
}
return Evaluation.EXCLUDE_AND_CONTINUE;
}
示例6: evaluate
import org.neo4j.graphdb.Path; //导入方法依赖的package包/类
@Override
public Evaluation evaluate(Path path) {
if (path.length() < length) {
return Evaluation.EXCLUDE_AND_CONTINUE;
}
Node lastNode = path.endNode();
if (!lastNode.hasLabel(Labels.AirportDay)){
return Evaluation.EXCLUDE_AND_CONTINUE;
} else if (destinations.contains( ((String)lastNode.getProperty("key")).substring(0,3) )) {
return Evaluation.INCLUDE_AND_PRUNE;
}
return Evaluation.EXCLUDE_AND_PRUNE;
}
示例7: getOrthologs
import org.neo4j.graphdb.Path; //导入方法依赖的package包/类
Collection<Node> getOrthologs(Node source) throws IOException {
Collection<Node> orthologs = new HashSet<>();
for (Path path : orthologDescription.traverse(source)) {
if (path.endNode().hasLabel(GENE_LABEL) && path.endNode() != source) {
orthologs.add(path.endNode());
}
}
return orthologs;
}
示例8: determineKeyEntities
import org.neo4j.graphdb.Path; //导入方法依赖的package包/类
private static void determineKeyEntities(final GraphDatabaseService graphDB, final AttributePath commonAttributePath,
final ContentSchema prefixedContentSchema, final Map<Long, CSEntity> csEntities, final Node... csEntityNodesArray) {
for (final AttributePath keyAttributePath : prefixedContentSchema.getKeyAttributePaths()) {
final Optional<LinkedList<Attribute>> optionalRelativeKeyAttributePath = determineRelativeAttributePath(keyAttributePath,
commonAttributePath);
if (optionalRelativeKeyAttributePath.isPresent()) {
final LinkedList<Attribute> relativeKeyAttributePath = optionalRelativeKeyAttributePath.get();
final Iterable<Path> relativeKeyPaths = graphDB.traversalDescription().depthFirst()
.evaluator(Evaluators.toDepth(relativeKeyAttributePath.size())).evaluator(new EntityEvaluator(relativeKeyAttributePath))
.traverse(csEntityNodesArray);
for (final Path relativeKeyPath : relativeKeyPaths) {
final Node keyNode = relativeKeyPath.endNode();
final Node csEntityNode = relativeKeyPath.startNode();
final String keyValue = (String) keyNode.getProperty(GraphStatics.VALUE_PROPERTY, null);
final KeyEntity keyEntity = new KeyEntity(keyNode.getId(), keyValue);
csEntities.get(csEntityNode.getId()).addKeyEntity(keyEntity);
}
} else {
LOG.debug("couldn't determine relative key attribute path for key attribute path '{}' and common attribute path ''",
keyAttributePath.toString(), commonAttributePath.toString());
}
}
}
示例9: determineValueEntities
import org.neo4j.graphdb.Path; //导入方法依赖的package包/类
private static void determineValueEntities(final GraphDatabaseService graphDB, final AttributePath commonAttributePath,
final ContentSchema contentSchema, final Map<Long, CSEntity> csEntities, final Node... csEntityNodesArray) {
final AttributePath valueAttributePath = contentSchema.getValueAttributePath();
final Optional<LinkedList<Attribute>> optionalRelativeValueAttributePath = determineRelativeAttributePath(
valueAttributePath,
commonAttributePath);
if (optionalRelativeValueAttributePath.isPresent()) {
final LinkedList<Attribute> relativeValueAttributePath = optionalRelativeValueAttributePath.get();
final Iterable<Path> relativeValuePaths = graphDB.traversalDescription().depthFirst()
.evaluator(Evaluators.toDepth(relativeValueAttributePath.size())).evaluator(new EntityEvaluator(relativeValueAttributePath))
.traverse(csEntityNodesArray);
for (final Path relativeValuePath : relativeValuePaths) {
final Node valueNode = relativeValuePath.endNode();
final Node csEntityNode = relativeValuePath.startNode();
final String valueValue = (String) valueNode.getProperty(GraphStatics.VALUE_PROPERTY, null);
final Long valueOrder = (Long) relativeValuePath.lastRelationship().getProperty(GraphStatics.ORDER_PROPERTY, null);
final ValueEntity valueEntity = new ValueEntity(valueNode.getId(), valueValue, valueOrder);
csEntities.get(csEntityNode.getId()).addValueEntity(valueEntity);
}
} else {
LOG.debug("couldn't determine relative value attribute path for value attribute path '{}' and common attribute path ''",
valueAttributePath.toString(), commonAttributePath.toString());
}
}
示例10: nodes
import org.neo4j.graphdb.Path; //导入方法依赖的package包/类
public Iterable<Node> nodes()
{
return new IterableWrapper<Node, Path>( this )
{
@Override
protected Node underlyingObjectToObject( Path position )
{
return position.endNode();
}
};
}
示例11: evaluate
import org.neo4j.graphdb.Path; //导入方法依赖的package包/类
@Override
public Evaluation evaluate(Path path) {
Node n = path.endNode();
UsageFacts facts = dao.readFacts(n.getId());
int size = facts == null ? -1 : facts.metrics.getNumDescendants() + facts.metrics.getNumSynonyms();
if (size > minChunkSize && (size < chunkSize || size - facts.metrics.getNumChildren() < minChunkSize)) {
chunkIds.add(n.getId());
return Evaluation.INCLUDE_AND_PRUNE;
} else {
return Evaluation.INCLUDE_AND_CONTINUE;
}
}
示例12: evaluate
import org.neo4j.graphdb.Path; //导入方法依赖的package包/类
@Override
public Evaluation evaluate(Path path) {
Node end = path.endNode();
Rank r = Rank.values()[(int) end.getProperty(NeoProperties.RANK, Rank.UNRANKED.ordinal())];
return r.isLinnean() ? Evaluation.INCLUDE_AND_CONTINUE : Evaluation.EXCLUDE_AND_CONTINUE;
}
示例13: evaluate
import org.neo4j.graphdb.Path; //导入方法依赖的package包/类
@Override
public Evaluation evaluate(Path path) {
Node end = path.endNode();
return end.hasLabel(Labels.SYNONYM) ? Evaluation.EXCLUDE_AND_CONTINUE : Evaluation.INCLUDE_AND_CONTINUE;
}
示例14: endsWithNode
import org.neo4j.graphdb.Path; //导入方法依赖的package包/类
/**
* Verifies that the actual {@link org.neo4j.graphdb.Path} ends with the given node<br/>
* <p>
* Example:
*
* <pre>
* GraphDatabaseService graph = new TestGraphDatabaseFactory().newImpermanentDatabase();
* // [...]
* Relationship love = homerNode.createRelationshipTo(doughnutNode, DynamicRelationshipType.withName("LOVES"));
* // PathExpander bellyExpander = [...]
* Path homerToDoughnutPath = GraphAlgoFactory.shortestPath(bellyExpander, 2).findSinglePath(homerNode, doughnutNode);
*
* assertThat(homerToDoughnutPath).endsWithNode(doughnutNode);
* </pre>
*
* If the <code>node</code> is {@code null}, an {@link IllegalArgumentException} is thrown.
* <p>
*
* @param node the expected end node of the actual {@link org.neo4j.graphdb.Path}
* @return this {@link org.assertj.neo4j.api.PathAssert} for assertions chaining
*
* @throws IllegalArgumentException if <code>node</code> is {@code null}.
* @throws AssertionError if the actual {@link org.neo4j.graphdb.Path} does not end with the given node
*/
public PathAssert endsWithNode(Node node) {
Objects.instance().assertNotNull(info, actual);
Path actualPath = getActual();
Node actualEnd = actualPath.endNode();
checkNullEndNodes(actualEnd, node);
if (!actualEnd.equals(node)) {
throw Failures.instance().failure(info, shouldEndWithNode(actualPath, node));
}
return this;
}
示例15: doesNotEndWithNode
import org.neo4j.graphdb.Path; //导入方法依赖的package包/类
/**
* Verifies that the given node is not the last one of the actual {@link org.neo4j.graphdb.Path}<br/>
* <p>
* Example:
*
* <pre>
* GraphDatabaseService graph = new TestGraphDatabaseFactory().newImpermanentDatabase();
* // [...]
* Relationship love = homerNode.createRelationshipTo(doughnutNode, DynamicRelationshipType.withName("LOVES"));
* // PathExpander bellyExpander = [...]
* Path homerToDoughnutPath = GraphAlgoFactory.shortestPath(bellyExpander, 2).findSinglePath(homerNode, doughnutNode);
*
* assertThat(homerToDoughnutPath).doesNotEndWithNode(saladNode);
* </pre>
*
* If the <code>node</code> is {@code null}, an {@link IllegalArgumentException} is thrown.
* <p>
*
* @param node the expected last node of the actual {@link org.neo4j.graphdb.Path}
* @return this {@link org.assertj.neo4j.api.PathAssert} for assertions chaining
*
* @throws IllegalArgumentException if <code>node</code> is {@code null}.
* @throws AssertionError if the actual {@link org.neo4j.graphdb.Path} ends with this node
*/
public PathAssert doesNotEndWithNode(Node node) {
Objects.instance().assertNotNull(info, actual);
Path actualPath = getActual();
Node actualEnd = actualPath.endNode();
checkNullEndNodes(actualEnd, node);
if (actualEnd.equals(node)) {
throw Failures.instance().failure(info, shouldNotEndWithNode(actualPath, node));
}
return this;
}