GitHub user dosubot[bot] edited a comment on the discussion: 关于电网拓扑数据导入
<!-- Answer -->
不需要为 LineSegment2LineSegment 这种同类型顶点之间的连接正反各写一遍边标签,只需定义一次 edgeLabel(比如
schema.edgeLabel("LineSegment2LineSegment")),即可支持 LineSegment → LineSegment
的边。HugeGraph 的边是有向的,A→B 和 B→A 是两条独立的边,想实现双向连接,只需在数据导入时生成两条边(A→B 和 B→A),都用同一个
edgeLabel 导入即可,无需再定义反向 edgeLabel。
比如:
```groovy
schema.edgeLabel("LineSegment2LineSegment")
.sourceLabel("LineSegment")
.targetLabel("LineSegment")
.properties()
.ifNotExist().create();
```
导入时,edge 数据里有 A→B 和 B→A 两条记录即可:
| from | to |
|------|-----|
| A | B |
| B | A |
这样查询时可以通过 direction 参数(OUT/IN/BOTH)获取正向、反向或双向的边,底层存储和 schema
仍然是有向的。[源码说明](https://github.com/apache/incubator-hugegraph/blob/master/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/schema/EdgeLabel.java)
只有在你需要区分正向和反向的语义(比如属性不同),才需要定义两个不同的 edgeLabel,否则只需一个
edgeLabel,数据里导入正反两条边即可。[详细机制](https://github.com/apache/incubator-hugegraph/blob/master/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/structure/HugeEdge.java)
如需具体 struct.json 或数据处理脚本示例可以继续补充需求。
<!-- Dosu Comment Footer -->
*To reply, just mention
[@dosu](https://go.dosu.dev/dosubot?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=reply-with-mention&utm_term=apache%2Fhugegraph).*
---
Docs are dead. Just use
[Dosu](https://dosu.dev?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=static-docs-tagline&utm_term=apache%2Fhugegraph).
[](https://app.dosu.dev/response-feedback?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=static-docs-feedback&utm_term=apache%2Fhugegraph#message_id=8ab82473-c187-4c88-a6a6-71e10542b295)
[](https://github.dosu.com/apache/hugegraph?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=static-docs-ask-repo&utm_term=apache%2Fhugegraph)
[](https://app.dosu.dev/signup?referrer=openSource&source=github-footer&utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=static-docs-share-team&utm_term=apache%2Fhugegraph)
GitHub link:
https://github.com/apache/hugegraph/discussions/2917#discussioncomment-15193044
----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]