dosubot[bot] commented on issue #2539:
URL: 
https://github.com/apache/incubator-hugegraph/issues/2539#issuecomment-2141161368

   <!-- Answer -->
   `edge.vertices(Direction.BOTH);` 返回一个迭代器对象而不是单个顶点对象,因为它可能会返回多个顶点。具体来说,当方向是 
`BOTH` 时,它包括边的源顶点和目标顶点。该方法设计用于处理不同的方向(`OUT`、`IN`、`BOTH`),在 `BOTH` 
的情况下,需要返回两个顶点,因此使用迭代器来容纳多个结果。
   
   ```java
   @Watched(prefix = "vertex")
   @Override
   public Iterator<Vertex> vertices(Direction direction, String... edgeLabels) {
       Iterator<Edge> edges = this.edges(direction, edgeLabels);
       return this.graph().adjacentVertices(edges);
   }
   ```
   
   这个代码片段来自 `HugeVertex` 类,显示了对于 `BOTH` 
方向,该方法检索两个方向的边,然后返回相邻顶点的迭代器。这种设计确保了方法能够高效地处理多个顶点<sup>[[1]](https://github.com/apache/incubator-hugegraph/blob/master/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/structure/HugeVertex.java)</sup><sup>[[2]](https://github.com/apache/incubator-hugegraph/blob/master/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/structure/HugeEdge.java)</sup>。
   
   
   <!-- Dosu Comment Footer -->
   *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to