MCPcopy Create free account
hub / github.com/diillson/chatcli / Neighbors

Method Neighbors

pkg/knowledge/graph.go:162–175  ·  view source on GitHub ↗

Neighbors returns the adjacent nodes ordered by edge weight (desc), then ID (asc) for stability.

(id string)

Source from the content-addressed store, hash-verified

160// Neighbors returns the adjacent nodes ordered by edge weight (desc), then ID
161// (asc) for stability.
162func (g *Graph) Neighbors(id string) []Neighbor {
163 adj := g.adj[id]
164 out := make([]Neighbor, 0, len(adj))
165 for nid, w := range adj {
166 out = append(out, Neighbor{ID: nid, Weight: w})
167 }
168 sort.Slice(out, func(i, j int) bool {
169 if out[i].Weight != out[j].Weight {
170 return out[i].Weight > out[j].Weight
171 }
172 return out[i].ID < out[j].ID
173 })
174 return out
175}
176
177// Hubs returns the most connected nodes (weighted degree, then intrinsic
178// weight, then ID), capped at limit. Hubs are the backbone of the index card.

Callers 5

NeighborhoodMethod · 0.95
TestNeighborsHubsSearchFunction · 0.80
KnowledgeGraphMethod · 0.80
TestBuildKnowledgeGraphFunction · 0.80
graphToDOTFunction · 0.80

Calls

no outgoing calls

Tested by 2

TestNeighborsHubsSearchFunction · 0.64
TestBuildKnowledgeGraphFunction · 0.64