Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GodNodes ¶
GodNodes returns the topN nodes sorted by total degree (in + out). These are the most-connected concepts in the graph — architectural hubs.
func RunLeiden ¶
RunLeiden runs Leiden community detection on the graph by delegating to the bundled Python script (scripts/leiden.py). Returns a map of node ID → community ID (0-indexed integers).
If Python or the script is unavailable, a clear error is returned (no panic). The script itself falls back to connected-components if graspologic is missing.
func SuggestedQuestions ¶
SuggestedQuestions returns 4–5 question templates populated with the names of the top god nodes. These are questions the graph is uniquely positioned to answer through path-finding and community analysis.
func SurpriseEdges ¶
SurpriseEdges returns the topN edges that cross community boundaries, ranked by the product of the degrees of their endpoints (a proxy for betweenness centrality: high-degree nodes in different communities that are directly connected are architecturally "surprising").
Types ¶
type Graph ¶
type Graph struct {
Directed *simple.DirectedGraph
NodeIndex map[string]int64 // node ID string → gonum int64 ID
NodeByID map[int64]types.Node // gonum int64 ID → types.Node
ResolvedEdges []types.Edge // only edges where both endpoints resolved
Nodes []types.Node
}
Graph wraps a gonum directed graph with auxiliary indexes for fast lookup.
func Build ¶
Build constructs a Graph from the provided nodes and edges.
Edge resolution:
- e.Source must match a node ID exactly (it is always in "<file>:<name>" format).
- e.Target is first tried as an exact ID, then as a bare label via labelIndex.
Only edges where BOTH endpoints resolve to known nodes are stored in ResolvedEdges and added to the gonum graph. Dangling edges (targeting stdlib/external symbols) are silently dropped — they add noise and break Obsidian graph view by creating isolated satellite dots.
func (*Graph) ApplyCommunities ¶
ApplyCommunities writes community IDs back onto the graph's node metadata and populates the community → []nodeID index for report generation.
func (*Graph) Communities ¶
Communities returns a map of communityID → list of node IDs (empty until clustering is run).
func (*Graph) Degree ¶
Degree returns the total degree (in + out) of the node with the given ID string.