本文整理匯總了Java中org.neo4j.graphdb.Direction.OUTGOING屬性的典型用法代碼示例。如果您正苦於以下問題:Java Direction.OUTGOING屬性的具體用法?Java Direction.OUTGOING怎麽用?Java Direction.OUTGOING使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類org.neo4j.graphdb.Direction
的用法示例。
在下文中一共展示了Direction.OUTGOING屬性的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: resolveRelationships
private Set<DirectedRelationshipType> resolveRelationships(String key, String value) {
Set<DirectedRelationshipType> rels = new HashSet<>();
String cypherIn = String.format("[%s:%s]", key, value);
String cypherOut = cypherUtil.resolveRelationships(cypherIn);
Matcher m = ENTAILMENT_PATTERN.matcher(cypherOut);
while (m.find()) {
String types = m.group(2);
String[] cypherRels = types.split("\\|");
for (String cypherRel : cypherRels) {
String unquotedCypherRel = cypherRel.replaceAll("^`|`$","");
RelationshipType relType = RelationshipType.withName(unquotedCypherRel);
DirectedRelationshipType dirRelType = new DirectedRelationshipType(relType, Direction.OUTGOING);
rels.add(dirRelType);
}
}
return rels;
}
示例2: closures_areReturned
@Test
public void closures_areReturned() {
DirectedRelationshipType type = new DirectedRelationshipType(OwlRelationships.RDFS_SUBCLASS_OF, Direction.OUTGOING);
Set<DirectedRelationshipType> types = newHashSet(type);
Closure closure = closureUtil.getClosure(c, types);
assertThat(closure.getCurie(), is("X:c"));
assertThat(closure.getLabel(), is("C"));
assertThat(closure.getCuries(), contains("X:c", "X:b", "X:a"));
assertThat(closure.getLabels(), contains("C", "X:b", "A"));
closure = closureUtil.getClosure(b, types);
assertThat(closure.getCurie(), is("X:b"));
assertThat(closure.getLabel(), is("X:b"));
assertThat(closure.getCuries(), contains("X:b", "X:a"));
assertThat(closure.getLabels(), contains("X:b", "A"));
closure = closureUtil.getClosure(a, types);
assertThat(closure.getCurie(), is("X:a"));
assertThat(closure.getLabel(), is("A"));
assertThat(closure.getCuries(), contains("X:a"));
assertThat(closure.getLabels(), contains("A"));
}
示例3: getDirectionFrom
/**
* Get the direction in which relationships are discovered using this
* relationship pattern from the specified node. May be
* {@link Direction#OUTGOING outgoing}, {@link Direction#INCOMING incoming},
* or {@link Direction#BOTH both}.
*
* @param fromNode the pattern node to find the direction of this pattern
* relationship from.
* @return the direction to discover relationships matching this pattern in.
*/
public Direction getDirectionFrom( PatternNode fromNode )
{
if ( !directed )
{
return Direction.BOTH;
}
if ( fromNode.equals( firstNode ) )
{
return Direction.OUTGOING;
}
if ( fromNode.equals( secondNode ) )
{
return Direction.INCOMING;
}
throw new RuntimeException( fromNode + " not in " + this );
}
示例4: getDirection
/**
* @return The direction to use when searching for relations/edges
*/
protected Direction getDirection()
{
if ( backwards )
{
if ( relationDirection.equals( Direction.INCOMING ) )
{
return Direction.OUTGOING;
}
if ( relationDirection.equals( Direction.OUTGOING ) )
{
return Direction.INCOMING;
}
}
return relationDirection;
}
示例5: multipleRelationships_areFollowed
@Test
public void multipleRelationships_areFollowed() {
DirectedRelationshipType type1 = new DirectedRelationshipType(OwlRelationships.RDFS_SUBCLASS_OF, Direction.OUTGOING);
DirectedRelationshipType type2 = new DirectedRelationshipType(OwlRelationships.RDF_TYPE, Direction.OUTGOING);
Set<DirectedRelationshipType> types = newHashSet(type1, type2);
Closure closure = closureUtil.getClosure(d, types);
assertThat(closure.getCurie(), is("X:d"));
assertThat(closure.getCurie(), is("X:d"));
assertThat(closure.getCuries(), contains("X:d", "X:c", "X:b", "X:a"));
assertThat(closure.getLabels(), contains("X:d", "C", "X:b", "A"));
}
示例6: isConnected
public static boolean isConnected(final Node source, final Node target, final RelationshipType relationshipType) {
final int sourceDegree = source.getDegree(relationshipType, Direction.OUTGOING);
final int targetDegree = target.getDegree(relationshipType, Direction.INCOMING);
final Direction searchDirection;
final Node searchSource;
final Node searchTarget;
if (sourceDegree <= targetDegree) {
searchDirection = Direction.OUTGOING;
searchSource = source;
searchTarget = target;
} else {
searchDirection = Direction.INCOMING;
searchSource = target;
searchTarget = source;
}
final Iterator<Relationship> edges = searchSource.getRelationships(searchDirection, relationshipType).iterator();
while (edges.hasNext()) {
final Relationship edge = edges.next();
final Node otherNode = edge.getOtherNode(searchSource);
if (searchTarget.equals(otherNode)) {
return true;
}
}
return false;
}
示例7: shouldCalculateOutDegreeCentralityArrayStorageSPI
@Test
public void shouldCalculateOutDegreeCentralityArrayStorageSPI() throws IOException {
DegreeArrayStorageParallelSPI outDegree = new DegreeArrayStorageParallelSPI(db, pool, Direction.OUTGOING);
outDegree.compute("Person", "ACTED_IN", 1);
long id = (long) getPersonEntry("Tom Hanks", db).get("id");
assertTrue("outDegree Centrality calculted incorrectly", 12 == outDegree.getResult(id));
}
示例8: getNextElement
private void getNextElement()
{
while ( nextElement == null && relItr.hasNext() )
{
Relationship possibleRel =
graphDbService.getRelationshipById( relItr.next() );
if ( dir == Direction.OUTGOING &&
possibleRel.getEndNode().getId() == nodeId )
{
continue;
}
if ( dir == Direction.INCOMING &&
possibleRel.getStartNode().getId() == nodeId )
{
continue;
}
if ( types != null )
{
for ( RelationshipType type : types )
{
if ( type.name().equals(
possibleRel.getType().name() ) )
{
nextElement = possibleRel;
break;
}
}
}
else
{
nextElement = possibleRel;
}
}
}
示例9: hasNext
public boolean hasNext()
{
if ( nextElement != null )
{
return true;
}
do
{
// if ( nextPosition < relIds.length )
if ( relIds.hasNext() )
{
int nextId = relIds.next();
try
{
Relationship possibleElement = nodeManager
.getRelationshipById( nextId );
if ( direction == Direction.INCOMING
&& possibleElement.getEndNode().equals( fromNode ) )
{
nextElement = possibleElement;
}
else if ( direction == Direction.OUTGOING
&& possibleElement.getStartNode().equals( fromNode ) )
{
nextElement = possibleElement;
}
else if ( direction == Direction.BOTH )
{
nextElement = possibleElement;
}
}
catch ( Throwable t )
{
log.log( Level.FINE,
"Unable to get relationship " + nextId, t );
}
}
}
while ( nextElement == null && relIds.hasNext() );
return nextElement != null;
}