[英]OrientDB can't get edges with direction.OUT
我正在尝试确定具有起始顶点和终止顶点的边。
为此,我打电话给:
vertexStart.getEdges(Direction.OUT, relationshipId)
这似乎总是空的。
获取传入的边缘似乎可行,但我需要两者。
vertexStart.getEdges(Direction.IN, relationshipId)
RelationshipId是边缘的标签。
Iterable<Vertex> startNodes = this.getVertexList(storage.getStartNode(), graph);
Iterable<Vertex> endNodes = this.getVertexList(storage.getEndNode(), graph);
for (Vertex startNode : startNodes)
{
for (Vertex endNode : endNodes)
{
String edgeClass = "class:" + storage.getId();
Edge edge = startNode.addEdge(edgeClass, endNode);
for (Map.Entry<String, Object> entry : storage.getProperties().entrySet())
{
edge.setProperty(entry.getKey(), entry.getValue());
}
edge.setProperty(Constants.TAG_HASH, HashCreator.sha1FromRelationship(storage));
edge.setProperty(Constants.TAG_SNAPSHOT_ID, snapshotId);
}
}
graph.commit();
用于创建结构。
我试图重现您的问题,并且在我的情况下有效。 我创建了这张图
顶点#10:0的输入边为1个边,输出为1个边。
我用了这段代码。
Vertex v = g.getVertex("#10:0");
System.out.println("OUT");
Iterable<Edge> itOut=v.getEdges(Direction.OUT, "E");
for(Edge e:itOut){
System.out.println(e.getId());
}
System.out.println("IN");
Iterable<Edge> itIn=v.getEdges(Direction.IN, "E");
for(Edge e:itIn){
System.out.println(e.getId());
}
我得到了
希望能帮助到你。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.