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

Function selectFullGraphNodes

cli/graph_command.go:87–109  ·  view source on GitHub ↗

selectFullGraphNodes returns the structural nodes to draw: tags are excluded (they are keyword glue that turns the view into a hairball). When the graph is small all remaining nodes show; otherwise only the top hubs, so a big graph renders a readable backbone.

(g *knowledge.Graph)

Source from the content-addressed store, hash-verified

85// small all remaining nodes show; otherwise only the top hubs, so a big graph
86// renders a readable backbone.
87func selectFullGraphNodes(g *knowledge.Graph) map[string]bool {
88 include := make(map[string]bool)
89 if g.Len() <= graphVizMaxNodes {
90 for _, n := range g.Nodes() {
91 if n.Kind == knowledge.KindTag {
92 continue
93 }
94 include[n.ID] = true
95 }
96 return include
97 }
98 // Pull extra hubs since some will be tags we skip.
99 for _, h := range g.Hubs(graphVizMaxNodes * 2) {
100 if h.Kind == knowledge.KindTag {
101 continue
102 }
103 include[h.ID] = true
104 if len(include) >= graphVizMaxNodes {
105 break
106 }
107 }
108 return include
109}
110
111// graphToDOT renders the included nodes and the edges among them as undirected
112// DOT for a force-directed layout: a solid dark canvas with light, wrapped

Callers 4

TestGraphToDOTFunction · 0.85
handleGraphCommandMethod · 0.85

Calls 3

NodesMethod · 0.80
HubsMethod · 0.80
LenMethod · 0.45

Tested by 3

TestGraphToDOTFunction · 0.68