org.neo4j.graphdb.Direction类的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(6.3k)|赞(0)|评价(0)|浏览(281)

本文整理了Java中org.neo4j.graphdb.Direction类的一些代码示例,展示了Direction类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Direction类的具体详情如下:
包路径:org.neo4j.graphdb.Direction
类名称:Direction

Direction介绍

[英]Defines relationship directions used when getting relationships from a node or when creating traversers.

A relationship has a direction from a node's point of view. If a node is the start node of a relationship it will be an #OUTGOING relationship from that node's point of view. If a node is the end node of a relationship it will be an #INCOMING relationship from that node's point of view. The #BOTH direction is used when direction is of no importance, such as "give me all" or "traverse all" relationships that are either #OUTGOING or #INCOMING.
[中]定义从节点获取关系或创建遍历器时使用的关系方向。
从节点的角度来看,关系有一个方向。如果一个节点是关系的起始节点,那么从该节点的角度来看,它将是一个#传出的关系。如果节点是关系的结束节点,则从该节点的角度来看,它将是一个#传入关系。当方向不重要时,如“全部给我”或“遍历所有”关系,即“传出”或“传入”,则使用“双向”。

代码示例

代码示例来源:origin: neo4j/neo4j

protected static RelationshipGroupRecord withRelationship( RelationshipGroupRecord group, Direction direction,
    long rel )
{
  switch ( direction )
  {
  case OUTGOING:
    group.setFirstOut( rel );
    break;
  case INCOMING:
    group.setFirstIn( rel );
    break;
  case BOTH:
    group.setFirstLoop( rel );
    break;
  default:
    throw new IllegalArgumentException( direction.name() );
  }
  return group;
}

代码示例来源:origin: neo4j/neo4j

@Override
  public String relationshipRepresentation( T path, Node from, Relationship relationship )
  {
    Direction direction = relationship.getEndNode().equals( from ) ? Direction.INCOMING : Direction.OUTGOING;
    StringBuilder builder = new StringBuilder();
    if ( direction.equals( Direction.INCOMING ) )
    {
      builder.append( "<" );
    }
    builder.append( "-[" + (relId ? relationship.getId() : "") );
    String representation = representation( relationship );
    if ( relId && !representation.equals( "" ) )
    {
      builder.append( "," );
    }
    builder.append( representation );
    builder.append( "]-" );
    if ( direction.equals( Direction.OUTGOING ) )
    {
      builder.append( ">" );
    }
    return builder.toString();
  }
};

代码示例来源:origin: neo4j/neo4j

private int idOffset( Direction direction )
{
  return BASE_IDS_OFFSET + (direction.ordinal() * ID_AND_COUNT_SIZE);
}

代码示例来源:origin: org.neo4j/neo4j-graph-collections

direction.reverse().name().equals( relationshipDirection ) )

代码示例来源:origin: neo4j/neo4j

@Test
public void canAddLoopRelationship()
{
  Node node = getGraphDb().createNode();
  node.createRelationshipTo( node, TEST );
  newTransaction();
  for ( Direction dir : Direction.values() )
  {
    int count = 0;
    for ( Relationship rel : node.getRelationships( dir ) )
    {
      count++;
      assertEquals( "start node", node, rel.getStartNode() );
      assertEquals( "end node", node, rel.getEndNode() );
      assertEquals( "other node", node, rel.getOtherNode( node ) );
    }
    assertEquals( dir.name() + " relationship count", 1, count );
  }
}

代码示例来源:origin: maxdemarzi/graph_processing

public DegreeArrayStorageParallelSPI(GraphDatabaseService db, ExecutorService pool, Direction direction) {
  this.pool = pool;
  this.db = (GraphDatabaseAPI)db;
  this.nodeCount = new NodeCounter().getNodeCount(db);
  this.direction = direction;
  if (!direction.equals(Direction.BOTH)) {
    directionName = direction.name().toLowerCase() + "_";
  }
}

代码示例来源:origin: com.graphaware.neo4j/timetree

private Direction resolveDirection(String direction) {
  if (direction == null) {
    return Direction.INCOMING;
  }
  return Direction.valueOf(direction.toUpperCase());
}

代码示例来源:origin: neo4j/neo4j

@Override
  public StandardExpander reverse()
  {
    return new AllExpander( direction.reverse() );
  }
}

代码示例来源:origin: neo4j-contrib/neo4j-apoc-procedures

public static Direction parseDirection(String direction) {
  if (null == direction) {
    return Direction.BOTH;
  }
  try {
    return Direction.valueOf(direction.toUpperCase());
  } catch (Exception e) {
    throw new RuntimeException(format("Cannot convert value '%s' to Direction. Legal values are '%s'",
        direction, Arrays.toString(Direction.values())));
  }
}

代码示例来源:origin: neo4j/neo4j

private static Map<Direction, Collection<RelationshipType>> temporaryTypeMap()
{
  Map<Direction, Collection<RelationshipType>> map = new EnumMap<>( Direction.class );
  for ( Direction direction : Direction.values() )
  {
    map.put( direction, new ArrayList<>() );
  }
  return map;
}

代码示例来源:origin: neo4j/neo4j

expectedCounts.get( spec.type )[spec.dir.ordinal()]++;
for ( Direction direction : Direction.values() )
  if ( counts[direction.ordinal()] > 0 )
    counts[direction.ordinal()]--;
    assertCounts( me, expectedCounts );
    if ( counter % 3 == 0 && counter > 0 )
expectedCounts.get( spec.type )[spec.dir.ordinal()]--;
assertCounts( me, expectedCounts );
if ( counter % 3 == 0 && counter > 0 )

代码示例来源:origin: stackoverflow.com

public class TestDirection {
  public static void main(String[] args) {
    System.out.printf("%10s: %-4s%n", "Direction", "Ordinal");
    for (Direction dir : Direction.values()) {
      System.out.printf("%10s: %-4d%n", dir.getText(), dir.ordinal());
    }
  }
}

代码示例来源:origin: neo4j-contrib/graph-collections

direction.reverse().name().equals( relationshipDirection ) )

代码示例来源:origin: com.graphaware.neo4j/timetree

private Direction resolveDirection(String direction) {
  if (direction == null) {
    return Direction.INCOMING;
  }
  return Direction.valueOf(direction.toUpperCase());
}

代码示例来源:origin: neo4j/neo4j

@Override
public StandardExpander reverse()
{
  Collection<Pair<RelationshipType, Direction>> newTypes = new ArrayList<>();
  for ( Pair<RelationshipType,Direction> pair : orderedTypes )
  {
    newTypes.add( Pair.of( pair.first(), pair.other().reverse() ) );
  }
  return new OrderedByTypeExpander( newTypes );
}

代码示例来源:origin: neo4j/neo4j

@Override
public StandardExpander remove( RelationshipType type )
{
  Map<Direction, Collection<RelationshipType>> tempMap = temporaryTypeMapFrom( typesMap );
  for ( Direction direction : Direction.values() )
  {
    tempMap.get( direction ).remove( type );
  }
  return createNew( toTypeMap( tempMap ) );
}

代码示例来源:origin: stackoverflow.com

public static MapLocation[] getLocs(Direction dir) {
 return valueOf(dir.name()).locs;
}

代码示例来源:origin: neo4j/neo4j

if ( relationDirection.equals( Direction.BOTH )
  || relationDirection.equals( Direction.OUTGOING ) )
if ( relationDirection.equals( Direction.BOTH )
  || relationDirection.equals( Direction.INCOMING ) )

代码示例来源:origin: SciGraph/SciGraph

@JsonCreator
public DirectedRelationshipType(@JsonProperty("type") String type, @JsonProperty("direction") String direction) {
 this.type = RelationshipType.withName(type);
 this.direction = Direction.valueOf(direction);
}

代码示例来源:origin: neo4j/neo4j

relDirection = direction.reverse();
  .nodeGetRelationships( read, cursors, nodeCursor, toNode, direction.reverse(), relTypes ), fromNode );

相关文章