MCPcopy Create free account
hub / github.com/astercloud/aster / GetLineageDepth

Method GetLineageDepth

pkg/memory/lineage.go:280–295  ·  view source on GitHub ↗

GetLineageDepth 获取记忆的谱系深度。 返回从根记忆到当前记忆的最长路径。

(memoryID string)

Source from the content-addressed store, hash-verified

278// GetLineageDepth 获取记忆的谱系深度。
279// 返回从根记忆到当前记忆的最长路径。
280func (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 获取谱系统计信息。
298type LineageStats struct {

Callers 2

GetLineageStatsMethod · 0.95

Calls 1

GetParentMemoriesMethod · 0.80

Tested by 1