ai_xiaopei
6 days ago 1196f409d86bc61e7596eb274840244a62ce84ba
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package graph
 
// Node 图节点(对应一个 markdown 文件)
type Node struct {
    ID        int64    `json:"id"`
    Path      string   `json:"path"`
    Title     string   `json:"title"`
    Section   string   `json:"section"`
    Tags      []string `json:"tags"`
    Entities  []string `json:"entities"`
    Wikilinks []string `json:"wikilinks"`
    Content   string   `json:"content"`
}
 
// Edge 图边(实体关系)
type Edge struct {
    FromNode int64  `json:"from_node"`
    ToNode   int64  `json:"to_node"` // 对于 tag/entity 边,ToNode 可以是虚拟节点 ID
    Relation string `json:"relation"` // "tag" | "entity" | "wikilink"
    Label    string `json:"label"`    // 具体值
}
 
// Graph 知识图谱
type Graph struct {
    Nodes []*Node
    Edges []*Edge
}