GetLineageDepth 获取记忆的谱系深度。 返回从根记忆到当前记忆的最长路径。
(memoryID string)
| 278 | // GetLineageDepth 获取记忆的谱系深度。 |
| 279 | // 返回从根记忆到当前记忆的最长路径。 |
| 280 | func (lm *LineageManager) GetLineageDepth(memoryID string) int { |
| 281 | parents := lm.graph.GetParentMemories(memoryID) |
| 282 | if len(parents) == 0 { |
| 283 | return 0 |
| 284 | } |
| 285 | |
| 286 | maxDepth := 0 |
| 287 | for _, parentID := range parents { |
| 288 | depth := lm.GetLineageDepth(parentID) |
| 289 | if depth > maxDepth { |
| 290 | maxDepth = depth |
| 291 | } |
| 292 | } |
| 293 | |
| 294 | return maxDepth + 1 |
| 295 | } |
| 296 | |
| 297 | // GetLineageStats 获取谱系统计信息。 |
| 298 | type LineageStats struct { |